magento seleccione SKU usando valores de atributo

enter image description here

I need to select SKU where partno = MEM1600-2U6D and brandname = Cisco and Condition = New

Can anybody provide me solution for this.

preguntado el 03 de mayo de 12 a las 13:05

Are you certain that Partno is capitalized in eav_attribute? Capitalized attribute codes are atypical in Magento. -

2 Respuestas

$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'),
))

I am not sure. Moreover you could try to use UNION's to achiveve your target.

Well I would try something lik this:

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'
)

Well you might

 GROUP by entity_id HAVING COUNT(*) = 3

something like this. Meaning if we have 3 entriies for entity_id it means it maches our case.

contestado el 03 de mayo de 12 a las 13:05

Where is the condition column?

EDIT: N/m, I just saw. You can't do it with that table setup. Condition / Brand would have to be a separate column or table, not value. With Condition in the value column, it has its own SKU, so you'd have 2 SKUs, one for the product and one for it's condition.

contestado el 03 de mayo de 12 a las 13:05

patno , brandname and condition are attributes - Tahseen Khan

What SKU are you expecting? MEM1600-2U6D has an SKU regardless of the brandname and condition. That SKU is 0001. Cisco also has the same SKU, and so does NEW. So that's 3 SKUs of 0001. An OLD MEM1600-2U6D would also have 3 SKUs, but those would be 0001, 0001, 0004. - Styphon

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.