Tag Archives: Magento tutorials online
Magento join two custom tables
Magento join two custom tables : You can join two custom tables in magento as below.
Magento join two custom tables Syntax
Following syntax is used for joining two tables in magento :
//load collection $collection = Mage::getModel('module/model_name')->getCollection(); $collection->getSelect()->join(Mage::getConfig()->getTablePrefix().'table_to_be_joined','main_table.table_field ='.Mage::getConfig()->getTablePrefix().'table_to_be_joined.table_field',array('field_name'));
Magento join two custom tables Example
$collection = Mage::getModel('sales/order')->getCollection(); $collection->getSelect()->join( array('order_item'=> 'sales_flat_order_item'), 'order_item.order_id = main_table.entity_id', array('order_item.sku'));
Magento join query in collection
Magento join query in collection : A simple join in magento is given as below:
Magento join query in collection Syntax
$collection = Mage::getModel('Module_name/Model_name')->getCollection(); $collection->getSelect()->join( array('table_alias'=> 'table_name'), 'condition', array('columns_name1'));
Magento join query in collection Example
$collection = Mage::getModel('sales/order')->getCollection(); $collection->getSelect()->join( array('order_item'=> 'sales_flat_order_item'), 'order_item.order_id = main_table.entity_id', array('order_item.sku'));
Magento call observer after customer login
Magento call observer after customer login : You Can call observer after customer login as below
Magento call observer after customer login
Add the following lines of code in your config.xml with details of your module.
singleton Namespace_ModuleName_Model_Observer Name_of_method
Magento call observer after customer delete
Magento call observer after customer delete : You can call observer after customer delete in magento as below.
Syntax of Magento call observer after customer delete
Add the following lines of code in your config.xml with details of your module.
singleton Namespace_ModuleName_Model_Observer Name_of_method
Magento call observer after order save commit
Magento call observer after order save commit as below.
Syntax of Magento call observer after order save commit
Add the following lines of code in your config.xml with details of your module.
singleton Namespace_ModuleName_Model_Observer Name_of_method
Magento call observer on checkout onepage checkout save billing
Magento call observer on checkout onepage checkout save billing as below.
Syntax of Magento call observer on checkout onepage checkout
Add the following lines of code in your config.xml with details of your module.
singleton Namespace_ModuleName_Model_Observer Name_of_method
Magento redirect from observer
Magento redirect from observer : You can redirect from magento observer as below.
Magento redirect from observer
$path = 'path to redirect'; Mage::app()->getResponse()->setRedirect(Mage::getUrl($path)); Mage::app()->getResponse()->sendResponse(); exit;
Magento redirect from observer Example
$path = 'checkout/onepage'; Mage::app()->getResponse()->setRedirect(Mage::getUrl($path)); Mage::app()->getResponse()->sendResponse(); exit;
Magneto get carts subtotal
Magneto get carts subtotal : You can get cart’s subtotal simply as below.
Magneto get carts subtotal Syntax
$cartSubTotal = Mage::helper('checkout/cart')->getQuote()->getSubtotal();
Which will return the subtotal of the cart.
Magento get base url
Magento get base url : You can get the base url in magento as following.
Magento get base url Syntax
Mage::getBaseUrl();
Which Will Return the current url.
For Cms Pages Or Static Blocks
{{store url=''}}