Magento Forum

Unable to get custom attribute in Shipping Module
 
cycore
Jr. Member
 
Total Posts:  10
Joined:  2008-09-20
 

Hi,
how can I get the value of an attribute? I’m trying to develop a shipping module.

public function getRate(Mage_Shipping_Model_Rate_Request $request{

    
foreach ($request->getAllItems() as $item{

        $product 
$item->getProduct();
        
$attributes $product->getAttributes();
        
// $attributes contains an array item named xyz, but I cannot find the value of it

        // I tried these:
        
$val1 $attributes['xyz']->getFrontend()->getValue($product);
        
$val2 $attributes['xyz']->getValue();
        
$val3 $product->getData('xyz');
        
$val4 $product->getXYZ();
        
$val5 $attributes['xyz']->getBackend()->getData($condition[0]);
        
$val6 $attributes['xyz']->getBackend()->getValue($product);
    
}
}

$product->_data contains all the regular attributes like price, weight and so on, but not the custom attribute I assigned to it in the admin panel.

I can display the value of the attribute in the frontend, by using this in my template:

$_product $this->getProduct();    
        
$_attributes $_product->getAttributes();
        if (
$_product->hasData('xyz')) {
            
echo $_attributes['xyz']->getFrontend()->getValue($_product);
        
}

Do you have any clue why this is not accessible in the shipping module? I tried many ways, and looked through every variable with XDebug, but I could not find anything....

Your help is greatly appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wilson Sheldon
Member
 
Total Posts:  47
Joined:  2008-06-07
 

Hi there,

I have the same issue.  Were you able to solve this?

Thanks,
Wilson

 
Magento Community Magento Community
Magento Community
Magento Community
 
Baseballtips
Sr. Member
 
Total Posts:  83
Joined:  2008-08-01
 

A while ago I was trying to create a shipping method for fixed shipping prices. The keystone of the method was a customer attribute I created called “fixed_shipping”. I was able to retrieve this value for an item by doing this:

$item->getfixed_shipping();
 
Magento Community Magento Community
Magento Community
Magento Community
 
EURO
Jr. Member
 
Total Posts:  23
Joined:  2009-02-26
 

Solved here: http://stackoverflow.com/questions/10267244/how-to-load-a-custom-product-attribute-into-a-quote-item

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