我需要从Magento v1.9.2.1中的数据库表中获取特定数据我能够找到产品表,但我不确定在哪里可以找到特定的数据。Magento v1.9.2.1产品表
我有需要,当你在Magento查看特定的产品来显示数据完全相同的一个桌面应用程序
这些都是我在Magento的数据库寻找数据 - SKU,产品名称,价格,图片,简短描述,长描述
我很难理解它的数据库结构。我真的很感激,如果有人能帮我找数据
我需要从Magento v1.9.2.1中的数据库表中获取特定数据我能够找到产品表,但我不确定在哪里可以找到特定的数据。Magento v1.9.2.1产品表
我有需要,当你在Magento查看特定的产品来显示数据完全相同的一个桌面应用程序
这些都是我在Magento的数据库寻找数据 - SKU,产品名称,价格,图片,简短描述,长描述
我很难理解它的数据库结构。我真的很感激,如果有人能帮我找数据
这可能会帮助你开始。我使用LINQPad能够对我的Magneto数据库编码c#。它允许我针对数据库编写一些高级代码,但仍可以看到生成的基础查询。
我产生这样的结果,我的查询:
+-----+-----+-------+---------------+-------------------+-----------------+
| sku | qty | price | special_price | special_from_date | special_to_date |
+-----+-----+-------+---------------+-------------------+-----------------+
| X1 | 5 | 13.99 | 8.99 | 2015-04-19 00:00 | |
| X2 | 12 | 10.99 | 7.99 | 2015-04-19 00:00 | |
| X3 | 9 | 9.99 | 5.99 | 2015-04-19 00:00 | |
+-----+-----+-------+---------------+-------------------+-----------------+
这里是(略简体)C#此数据查询:
var items =
from x in catalog_product_entity
join stock in cataloginventory_stock_item on x.entity_id equals stock.product_id
join price in catalog_product_entity_decimal.Where(_ => _.attribute_id == 75 && _.store_id == 0) on x.entity_id equals price.entity_id into prices
join special_price in catalog_product_entity_decimal.Where(_ => _.attribute_id == 76 && _.store_id == 0) on x.entity_id equals special_price.entity_id into special_prices
join special_from_date in catalog_product_entity_datetime.Where(_ => _.attribute_id == 77 && _.store_id == 0) on x.entity_id equals special_from_date.entity_id into special_from_dates
join special_to_date in catalog_product_entity_datetime.Where(_ => _.attribute_id == 78 && _.store_id == 0) on x.entity_id equals special_to_date.entity_id into special_to_dates
select new
{
x.sku,
stock.qty,
prices,
special_prices,
special_from_dates,
special_to_dates,
};
这将产生这些实际的SQL调用数据库:
SELECT t2.entity_id, t2.attribute_id, t2.entity_type_id, t2.store_id, t2.value, t2.value_id
FROM catalog_product_entity AS t0
INNER JOIN cataloginventory_stock_item AS t1
ON (t0.entity_id = t1.product_id)
LEFT OUTER JOIN catalog_product_entity_decimal AS t2
ON (((t2.attribute_id = 75) AND (t2.store_id = 0)) AND (t2.entity_id = t0.entity_id))
SELECT t2.entity_id, t2.attribute_id, t2.entity_type_id, t2.store_id, t2.value, t2.value_id
FROM catalog_product_entity AS t0
INNER JOIN cataloginventory_stock_item AS t1
ON (t0.entity_id = t1.product_id)
LEFT OUTER JOIN catalog_product_entity_decimal AS t2
ON (((t2.attribute_id = 76) AND (t2.store_id = 0)) AND (t2.entity_id = t0.entity_id))
SELECT t2.entity_id, t2.attribute_id, t2.entity_type_id, t2.store_id, t2.value, t2.value_id
FROM catalog_product_entity AS t0
INNER JOIN cataloginventory_stock_item AS t1
ON (t0.entity_id = t1.product_id)
LEFT OUTER JOIN catalog_product_entity_datetime AS t2
ON (((t2.attribute_id = 77) AND (t2.store_id = 0)) AND (t2.entity_id = t0.entity_id))
SELECT t2.entity_id, t2.attribute_id, t2.entity_type_id, t2.store_id, t2.value, t2.value_id
FROM catalog_product_entity AS t0
INNER JOIN cataloginventory_stock_item AS t1
ON (t0.entity_id = t1.product_id)
LEFT OUTER JOIN catalog_product_entity_datetime AS t2
ON (((t2.attribute_id = 78) AND (t2.store_id = 0)) AND (t2.entity_id = t0.entity_id))
SELECT t0.sku, t1.qty, t0.entity_id
FROM catalog_product_entity AS t0
INNER JOIN cataloginventory_stock_item AS t1
ON (t0.entity_id = t1.product_id)
现在,您确实需要知道attribute_id
值的用途你的数据库。
我用这个C#查询的是:
var query =
from et in eav_entity_type
where et.entity_model == "catalog/product"
join a in eav_attribute on et.entity_type_id equals a.entity_type_id
select new
{
a.attribute_id,
a.attribute_code,
a.backend_type
};
它转换为这个SQL:
SELECT t1.attribute_id, t1.attribute_code, t1.backend_type
FROM eav_entity_type AS t0
INNER JOIN eav_attribute AS t1
ON (t0.entity_type_id = t1.entity_type_id)
WHERE (t0.entity_model = @p0)
-- p0 = [catalog/product]
这给了我这样的结果:
+--------------+------------------------+--------------+
| attribute_id | attribute_code | backend_type |
+--------------+------------------------+--------------+
| 108 | category_ids | static |
| 92 | color | int |
| 79 | cost | decimal |
| 117 | country_of_manufacture | varchar |
| 115 | created_at | static |
| 103 | custom_design | varchar |
| 104 | custom_design_from | datetime |
| 105 | custom_design_to | datetime |
| 106 | custom_layout_update | text |
| 72 | description | text |
+--------------+------------------------+--------------+
然后使用后端类型来产生SQL的snippits的LEFT OUTER JOIN catalog_product_entity_datetime AS t2 ON (((t2.attribute_id = 78)
。