2016-02-02 225 views
-3

我想查詢一個magento數據庫來顯示Sku,產品名稱,ProductDetails,價格,WholesalePrice和Storedunits。 我有這個疑問Magento sql查詢產品詳細信息

 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,產品名稱和產品詳細,但我找不到領域

+1

「找不到剩餘的字段」是什麼意思?請顯示示例輸入,輸出,所需輸出。 – philipxy

+0

以上查詢返回sku,productname,productdetails。我想要返回價格,WholesalePrice和Storedunits字段,但我不知道如何搜索它們 –

+0

謝謝,但這只是重複您之前所說的內容。什麼是「搜索他們」的意思?請用更多的單詞。你想知道他們在哪個表嗎? – philipxy

回答

0

a tutorial的休息:

例如,所有的價格和其他十進制屬性存儲在catalog_product_entity_decimal其中所有短文本字符串存儲在catalog_product_varchar。要確定每個屬性存儲在哪個表中,Magento使用表eav_attribute中的列backend_type

相關問題