Saturday, 5 March 2011

get collection of customer all address in magento


Use the following code to retrieve all address of customer with the help of its email id.


<?php
$websiteid = Mage::app()->getwebsite->getid();
$store = Mage::app()->getStore();

$customer = Mage::getModel("customer/customer");
$customer->website_id = $websiteid;
$customer->setStore($store);
$customer->loadByEmail("dexte@yahoo.com");
$address = Mage::getModel("Customer/Entity_Address_Collection");
$address->setCustomerFilter($customer);
$addtess->load();
?>

Thursday, 3 March 2011

display product in magento with sql in list.phtml file

Place this following code in your  phtml file where you want to display particular category products this will return array of products and you can use this array to display product of particular category.
$sql = “SELECT product_id  FROM catalog_category_product WHERE category_id=57″;
$data = Mage::getSingleton(‘core/resource’) ->getConnection(‘core_read’)->fetchAll($sql);

Happy Coding...