Mysql magento使用属性值选择SKU

Mysql magento使用属性值选择SKU,mysql,magento,Mysql,Magento,我需要选择零件号=MEM1600-2U6D和品牌名=Cisco的SKU 和条件=新 谁能为我提供解决方案。条件列在哪里 编辑:N/m,我刚看到。你不能用那个表格设置。条件/品牌必须是单独的列或表,而不是值。在值列中有条件时,它有自己的SKU,因此您将有2个SKU,一个用于产品,另一个用于其条件 $collection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToSelect('*') ->addFie

我需要选择零件号=MEM1600-2U6D和品牌名=Cisco的SKU 和条件=新


谁能为我提供解决方案。

条件列在哪里

编辑:N/m,我刚看到。你不能用那个表格设置。条件/品牌必须是单独的列或表,而不是值。在值列中有条件时,它有自己的SKU,因此您将有2个SKU,一个用于产品,另一个用于其条件

$collection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToSelect('*') ->addFieldToFilter(array( array('attribute'=>'partno','eq'=>'MEM1600-2U6D'), )) ->addFieldToFilter(array( array('attribute'=>'brandname','eq'=>'Cisco'), )) ->addFieldToFilter(array( array('attribute'=>'condition','eq'=>'New'), ))
像这样的。也就是说,如果实体id有3个输入项,这意味着它符合我们的情况。

patno、brandname和condition是属性。您期望的SKU是什么?无论品牌名称和条件如何,MEM1600-2U6D都有一个SKU。那个SKU是0001。思科也有同样的SKU,新的也有。这就是0001的3个SKU。旧的MEM1600-2U6D也会有3个SKU,但这些SKU是00010010004。您确定零件号在eav_属性中是大写的吗?大写属性代码在Magento中是非典型的。 SELECT sku FROM catalog_product_entity WHERE entity_id in ( SELECT entity_id from catalog_product_entity_varchar WHERE attribute_id = (SELECT attribute_id from eav_attribute WHERE name='Partno' LIMIT 1) AND value = 'MEM1600-2U6D' UNION SELECT entity_id from catalog_product_entity_varchar WHERE attribute_id = (SELECT attribute_id from eav_attribute WHERE name='brandname' LIMIT 1) AND value = 'Cisco' UNION SELECT entity_id from catalog_product_entity_varchar WHERE attribute_id = (SELECT attribute_id from eav_attribute WHERE name='Condition' LIMIT 1) AND value = 'new' )
 GROUP by entity_id HAVING COUNT(*) = 3