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

Error when trying to getWeight()
 
twosheds
Jr. Member
 
Total Posts:  4
Joined:  2009-06-17
 

Hi,

I’m trying to get products’ weights, so I can report this on the checkout page, in the table next to Qty.

I’ve created myself a custom class with a method called get_basket_item_weight(). I am calling this from
app/design/frontend/default/default/template/checkout/cart/item/default.phtml, passing in $_item.

In my method, I just want to get the product’s weight and then multiply it by qty etc. So far I have this:

$prod_id $item->getId();
$qty $item->getQty();
$prod = new Mage_Catalog_Model_Product();
$prod->load($prod_id);

So far, so good. I now have a product populated from the database…

But then I do the obvious to get the weight:

$unit_weight $prod->getWeight();

But this gives me an error:

Notice: Undefined index:  in /home/tmpsvr4/domains/escape.tmpsvr4.co.uk/public_html/app/code/core/Mage/Catalog/Model/Product/Type.php on line 77

How do I get round this? After some googling, I’ve tried a few things to discover, and set, the product type, but no luck so far.

thanks,

- Kev

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