चुनें e
। entity_id
, आईएफ (at_name.value_id> 0, at_name.value, at_name_default।मूल्य) name
के रूप में,
pcategory_name.value AS 'PCat',
eaov.value AS 'brand',
stoke.stock_status AS 'inStoke',
pcategory_name.entity_id AS 'cat_id',
ccei.`value` AS 'is_active'
से catalog_product_entity
के रूप में e
अंदरूनी शामिल हों catalog_product_entity_varchar
के रूप में at_name_default
पर (at_name_default
। entity_id
= e
। entity_id
) और (at_name_default
। attribute_id
= (से eav_attribute
ईए वाम attribute_id चयन में शामिल हों eav_entity_type
और ea.entity_type_id = et.entity_type_id पर जहां ea
। attribute_code
= 'name' AN डी et.entity_type_code = 'catalog_product')) और at_name_default
। store_id
= 0 बायाँ शामिल हों catalog_product_entity_varchar
के रूप में at_name
पर (at_name
। entity_id
= e
। entity_id
) और (at_name
। attribute_id
= (eav_attribute
ईए से attribute_id का चयन करें बाईं तरफ ea.entity_type_id = et.entity_type_id कहां ea
। attribute_code
eav_entity_type
एट शामिल हों = 'नाम' और et.entity_type_code = 'catalog_product')) और (at_name
। store_id
= 1) वाम cataloginventory_stock_status
के शामिल होते ही stoke
पर (stoke
। product_id
= e
। entity_id
)
LEFT JOIN
`catalog_product_entity_varchar` AS `key`
ON (`key`.`entity_id` = `e`.`entity_id`)
AND key.attribute_id = 160
अंदरूनी pcategory
pcategory.entity_id पर के रूप में शामिल हों catalog_category_entity
= (मैक्स (category_id का चयन करें) catalog_category_product से कहां product_id = e.entity_id और category_id! = 2)
अंदरूनी शामिल हों catalog_category_entity_int
ccei पर के रूप में ccei। entity_id
= पीसी श्रेणी। entity_id
और सीसीआई। attribute_id
= 34
LEFT JOIN `catalog_category_entity_varchar` AS `pcategory_name` ON pcategory_name.entity_id = pcategory.entity_id AND pcategory_name.attribute_id = 33
वाम cpei
cpei पर के रूप में catalog_product_entity_int
शामिल हों। entity_id
= e
। entity_id
और cpei.entity_type_id = 4 और cpei.attribute_id = 70
वाम catalog_product_entity_int
cpeis
रूप में शामिल होने cpeis पर। entity_id
= e
। entity_id
AND cpeis.attribute_id = 155
LEFT JOIN eav_attribute_option_value AS `eaov` ON eaov.option_id = cpei.value
WHERE ccei.`value`=1 AND pcategory.parent_id=2
स्रोत
2015-06-17 06:16:39
यह सही जवाब है, ठीक है। 'echo $ संग्रह-> getSelectSql (सत्य);' –
मेरी मूल टिप्पणी में सुधार। यह 'echo $ संग्रह-> लोड() -> getSelectSql (true)' ' –