In magento helpers is very useful functionality.Basically we can call helper functions anywhere in the site .
Each module has its own helper function
like in magento you use a below cart helper function to get cart url
Mage::helper('checkout/cart')->getCartUrl()
the above helper function is created at below location
app/code/core/Mage/Checkout/Helper/Cart.php
Lets create one new helper function in the end of Cart.php
let say we need a function in which we need to get all ordered product items data
For this i have create a new function as below
public function getordered_products_data($order_id){
$cart = Mage::getModel('sales/order')->load($order_id);
print_r($cart->getData());die;
foreach ($cart->getAllItems() as $item) {
$loadproduct = Mage::getModel('catalog/product')->load($item->getProduct()->getId());
print_r($loadproduct->getData());
}
}
and now we can use this function anywhere in the site as below
Mage::helper('checkout/cart')->getordered_products_data($your_order_id); // pass your order id here
and with this you can see all products data in order anywhere in the site by using above function.
thanks and hope it will help the magento comunity
Each module has its own helper function
like in magento you use a below cart helper function to get cart url
Mage::helper('checkout/cart')->getCartUrl()
the above helper function is created at below location
app/code/core/Mage/Checkout/Helper/Cart.php
Lets create one new helper function in the end of Cart.php
let say we need a function in which we need to get all ordered product items data
For this i have create a new function as below
public function getordered_products_data($order_id){
$cart = Mage::getModel('sales/order')->load($order_id);
print_r($cart->getData());die;
foreach ($cart->getAllItems() as $item) {
$loadproduct = Mage::getModel('catalog/product')->load($item->getProduct()->getId());
print_r($loadproduct->getData());
}
}
and now we can use this function anywhere in the site as below
Mage::helper('checkout/cart')->getordered_products_data($your_order_id); // pass your order id here
and with this you can see all products data in order anywhere in the site by using above function.
thanks and hope it will help the magento comunity
Great article! I think this article will support and complement your point
ReplyDeleteFlorida Web Development
thanks for the apprecation
DeleteOh, this is a great way to help the community! Thanks for your input!
ReplyDelete