mercredi 19 novembre 2014

Magento get all product options by product


Vote count:

0




I'm trying to get all the product options for a product, and if it has more than 1 a popup has to appear.

So for instance if a product has 3 colors available a popup has to display, while a product with only one color doesn't display a popup.


I've placed the following code I found here in my list.phtml in the foreach product loop:



$attributeCode = 'kleur';

$product = Mage::getModel('catalog/product')->load($_product->getId());
$productCollection = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', $attributeCode);

$attribute = $productCollection->getFirstItem()->setEntity($product->getResource());

$options = $attribute->getSource()->getAllOptions(false);


But this returns all available attributes options i'm guessing it has something to do with the last line. But I really have no idea what to change it to.



asked 46 secs ago







Magento get all product options by product

Aucun commentaire:

Enregistrer un commentaire