Magento sql查询产品详细信息

时间:2016-02-02 21:20:22

标签: mysql sql magento

我想查询magento数据库以显示Sku,productname,ProductDetails,price,WholesalePrice和Storedunits。 我有这个查询

       SELECT 
    `e`.`sku`,"
    IF(at_name.value_id > 0, at_name.value, at_name_default.value) AS `name`, "
    IF(at_description.value_id > 0, at_name.value, at_description_default.value) AS `description` "

     FROM "
    `catalog_product_entity` AS `e` "
    INNER Join "
     `catalog_product_entity_varchar` AS `at_name_default` "
           ON (`at_name_default`.`entity_id` = `e`.`entity_id`) AND "
              (`at_name_default`.`attribute_id` = (SELECT attribute_id FROM `eav_attribute` ea LEFT JOIN `eav_entity_type` et ON ea.entity_type_id = et.entity_type_id  WHERE `ea`.`attribute_code` = 'name' AND et.entity_type_code = 'catalog_product')) AND "
              `at_name_default`.`store_id` = 0 "
    Left Join "
      `catalog_product_entity_varchar` AS `at_name` "
           ON (`at_name`.`entity_id` = `e`.`entity_id`) AND "
              (`at_name`.`attribute_id` = (SELECT attribute_id FROM `eav_attribute` ea LEFT JOIN `eav_entity_type` et ON ea.entity_type_id = et.entity_type_id  WHERE `ea`.`attribute_code` = 'name' AND et.entity_type_code = 'catalog_product')) AND "
              (`at_name`.`store_id` = 1) "
    INNER Join "
     `catalog_product_entity_text` AS `at_description_default` "
           ON (`at_description_default`.`entity_id` = `e`.`entity_id`) AND "
              (`at_description_default`.`attribute_id` = (SELECT attribute_id FROM `eav_attribute` ea LEFT JOIN `eav_entity_type` et ON ea.entity_type_id = et.entity_type_id  WHERE `ea`.`attribute_code` = 'description' AND et.entity_type_code = 'catalog_product')) AND "
              `at_description_default`.`store_id` = 0 "
    Left Join "
      `catalog_product_entity_text` AS `at_description` "
           ON (`at_description`.`entity_id` = `e`.`entity_id`) AND "
              (`at_description`.`attribute_id` = (SELECT attribute_id FROM `eav_attribute` ea LEFT JOIN `eav_entity_type` et ON ea.entity_type_id = et.entity_type_id  WHERE `ea`.`attribute_code` = 'description' AND et.entity_type_code = 'catalog_product')) AND "
              (`at_description`.`store_id` = 1) 

返回Sku,ProductName和ProductDetails但我找不到其余的字段

1 个答案:

答案 0 :(得分:0)

来自Here is the pictorial for the aforementioned problem

  

例如,所有价格和其他小数属性都存储在 catalog_product_entity_decimal 中,因为所有短文本字符串都存储在 catalog_product_varchar 中。为了确定每个属性存储在哪个表中,Magento使用表 eav_attribute 中的 backend_type 列。