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

How to extend View.php? 
 
Sintax
Member
 
Total Posts:  58
Joined:  2008-02-18
Hungary
 

Hi,

What is the recommended way of adding a new function to app/code/core/Mage/Catalog/Block/Product/View.php?

I want to add the following function:

public function getAdditionalDataEx()
    
{
        $data 
= array();
        
$product $this->getProduct();
        
//print_r($product->getData());
        //die;
        
$attributes $product->getAttributes();
        foreach (
$attributes as $attribute{
            
if ($product->getSuperAttributesIds() && (in_array($attribute->getAttributeId(), $product->getSuperAttributesIds()) || !$attribute->getUseInSuperProduct())) {
                
continue;
            
}
            
if ($attribute->getIsUserDefined()) {

                $value 
$attribute->getFrontend()->getValue($product);
                if (
strlen($value)) {
                    $data[$attribute
->getAttributeCode()= array(
                       
'key' => $attribute->getAttributeCode(),
                       
'attr_id' => $attribute->getId(),
                       
'label' => $this->__($attribute->getFrontend()->getLabel()),
                       
'value' => $attribute->getFrontend()->getValue($product)//$product->getData($attribute->getAttributeCode())
                    
);
                
}
            }
        }
        
return $data;
    
}

I need the attribute ‘key’ since in the phtml I create a custom layout placing specific attributes if they exist to specific locations.

::Sintax

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top