If for some reason you have list of products skus, and for each you need to fetch out it’s name, you will better not use the old way of $pname = Mage::getSingleton(“catalog/product”)->load(Mage::getSingleton(“catalog/product”)->getIdBySku($productSku))->getName(); because it will slow up dramatically your site. Better use the following piece of code: <?php $productSku = 'sku1'; $pname...
Read more
Get the Parent URL of a Child Product
In this post I will show you how to get the parent URL of a child product EFFICIENTLY (that means, unlike the very common mistake most Magento developers do, it is a way that will not slow your website down). Let’s say you have configurable products in your Magento site. Each configurable...
Read more
Writing a Magento Extension – part2
On this part, we will make the text “Hello World” appear inside the Magento design. For this, go to app/code/local/Engineering/Helloworld/controllers/IndexController.php and change its code to following: <?php class Engineering_Helloworld_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { $this->loadLayout(); $this->renderLayout(); } } A short explanation: When calling to $this->loadLayout(); Magento will go to “app/design/myinterface/mytheme/layout”...
Read more
Writing a Magento Extension – part1
In this tutorial we will create a Magento extension step by step. our extension will print “Hello World” to the screen. Go to “app/code/local” and create a new folder. name it “Packagename” – the “Packagename” is likely to be your company name – this folder will serve all the extensions that will...
Read more
Find Out The SQL Query That Was Used To Retrieve A Collection
To find out the SQL query Magento uses to retrieve a specific collection, just do the following: Let’s say you would like to know what query is used to get a product collection – go to your debugging area (or maybe some phtml file), and paste following code: $_productCollection = Mage::getResourceModel("catalog/product_collection");...
Read more
Changing The Select After The Collection Has Been Loaded
Lets observe at the following example: For some reason you want to show the products whose price is lower than 100$. If you go to list.phtml at app/design/frontend/base/default/template/catalog/product, you will see the following line: $_productCollection=$this->getLoadedProductCollection(); $_productCollection is instance of Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection, and of course this is already loaded collection (collection that has items)....
Read more
The Architecture of Magento Layered Navigation
So how actually does Magento Layered Navigation work? It may sound surprising, but a chunk of code that triggers all the functionality of the layered navigation, is placed in “Mage_Catalog_Block_Layer_View”, inside the function “_prepareLayout()”. When is the function _prepareLayout being called? The function “_prepareLayout()” exists in every block, and it’s being called...
Read more
What is Magento Layered Navigation
This article is the first article within the sequences of articles/tutorials about Magento Layered Navigation. What is Magento Layered Navigation? Magento Layered Navigation is a piece of functionality that allows customers to filter categories in the following way: If you have to example a category named “Apparel” and the products inside this...
Read more