mysql语句根据sku 查询magento的产品名

答案来自http://stackoverflow.com/questions/5323102/magento-products-import-from-database-using-sql-query

第一步,找出各个属性对应的attribute_code

select attribute_code, attribute_id, backend_type from eav_attribute
    where entity_type_id = (select entity_type_id from eav_entity_type where entity_type_code = 'catalog_product')
      and attribute_code in ('name', 'url_path', 'price', 'image', 'description', 'manufacturer');

一般结果为

+----------------+--------------+--------------+
| attribute_code | attribute_id | backend_type |
+----------------+--------------+--------------+
| description    |           61 | text         |
| image          |           74 | varchar      |
| manufacturer   |           70 | int          |
| name           |           60 | varchar      |
| price          |           64 | decimal      |
| url_path       |           87 | varchar      |
+----------------+--------------+--------------+

对应的name是60

第二步

select p.sku, p.entity_id, n.value name
    from catalog_product_entity p
    join catalog_product_entity_varchar n on n.entity_id = p.entity_id
  where n.attribute_id = 60 AND p.sku='001-C';

可以得出结果了,其他属性自己添加查询

再次感谢Joseph Mastey的回答