Data Accessing Methods from Within Various Scopes

Last modified by harikaram on Thu, June 24, 2010 16:32
Source|Old Revisions  

This is an old revision of the document!


Accessing a Product in the Cart

Current Scope:

An extension of Mage_Payment_Model_Method_Abstract (payment module Model) or anywhere with an getOrder() method

Desired Entity:

Mage_Catalog_Model_Product of an item in the cart

Code:

Gets the Mage_Catalog_Model_Product of the first item in the cart...

  1. $item = current( $this->getOrder()->getAllItems() );       
  2. $prod = Mage::getModel( 'catalog/product' )
  3.     ->load( $item->getProductId() );

Notes:

An “item” is another class altogether and lacks methods for returning a product or accessing things like custom product attributes.




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs