Show product attributes in list.phtml - Magento

前端 未结 4 1818
有刺的猬
有刺的猬 2021-01-03 06:39

Hello I have read many posts about this, and while it works its not complete.

For example; Attribute 1= shoesize and attribute 2 = shoe color. Both are in a dropdown

4条回答
  •  执念已碎
    2021-01-03 06:58

    Here is the code get attribute name and value that that doesn't belongs to any product

    $attributeCode = 'YOUR_ATTRIBUTE_CODE';
    
    $product = Mage::getModel('catalog/product');
    
    $productCollection = Mage::getResourceModel('eav/entity_attribute_collection')
       ->setEntityTypeFilter($product->getResource()->getTypeId())
       ->addFieldToFilter('attribute_code', $attributeCode);
    
    $attribute = $productCollection->getFirstItem()->setEntity($product->getResource());
    print_r($attribute->getData()); // print out the available attributes
    
    $options = $attribute->getSource()->getAllOptions(false);
    print_r($options); // print out attribute options
    

提交回复
热议问题