Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Echo Custom Attribute’s Value in Custom Options Template
 
zep007
Sr. Member
 
Avatar
Total Posts:  131
Joined:  2008-05-15
Connecticut
 

Hello,

I am building a swatch picker (have built actually) and have it working for the configurable products with no issues.  Im storing the delimited swatch information in a text box attribute called ‘swatches’ and pulling it out to build a java collapsible div with the images in it. 

Im using the code:

nl2br($_product->$swatch())

to pull this information from the attribute.

Works like a charm with configurables (configurable.phtml), but is giving an error with simple products’ custom options ( select.phtml )

the error is as follows:

Fatal error: Method name must be a string

If I try to do

$_product->getAttributeText('manufacturer')
I get

Fatal error: Call to a member function getAttributeText() on a non-object

I also tried putting

$_product    $this->getProduct();
$_attributes Mage::helper('core')->decorateArray($this->getAllAttributes());

above this.

Any suggestions??

 
Magento Community Magento Community
Magento Community
Magento Community
 
zep007
Sr. Member
 
Avatar
Total Posts:  131
Joined:  2008-05-15
Connecticut
 

Haven’t had any luck with this one yet.. Any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
elfling
Enthusiast
 
Avatar
Total Posts:  901
Joined:  2008-10-21
 

$cModel Mage::getModel('catalog/product');
                  
$cModel->load($_product->getId());
                  
$attributes Mage::getResourceModel('eav/entity_attribute_collection')
                  ->
setEntityTypeFilter($_product->getResource()->getTypeId())
                  ->
addFieldToFilter('attribute_code''manufacturer');
                  
$attribute $attributes->getFirstItem()->setEntity($_product->getResource());
                  echo 
$attribute->getSource()->getOptionText($cModel->getData('manufacturer')); 
   
?>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top