In one of my project we had a two level category hierarchy. Clicking on the top level category displayed a promotional banner and the sub-categories. The second level category page displayed the products. In this post we will discuss how we can display the subcategories on a category page. We are not going to create any new module.
STEP 1: Create a PHTML file
First we create a phtml file {{MAGENTO_ROOT}}\app\design\frontend\rwd\mytheme\template\catalog\category\subcategories.phtml
In order to reduce the initial load time of page, it is recommended to move all the JS includes in the <head> section of web page to the footer. Lets see how we can do it in Magento.
Step 1: Add Layout Updates
Create a child block of “before_body_end” named “foot” similar to the head block in local.xml file as shown below:
<?xml version="1.0" ?> <layout version="0.1.0"> <default> <reference name="before_body_end"> <block type="page/html_head" name="foot" as="foot" after="-" template="page/html/foot.phtml"/> </reference> </default> </layout>
There might have been a situation when you would have created a special category like “Sale Products” or “Featured Products”… and you had wanted to display products from these categories on some page like Home Pages using the CMS static block.
In order to achieve this you may create a CMS static block and add the following segment of code:
{{block type="catalog/product_list" name="product_list" category_id="2" column_count="4" template="catalog/product/list.phtml" }}
This will display the products listing page as a block on the page.
If you have a requirement to remove breadcrumb from certain pages say the Magento CMS Pages then you can simply follow the 2 steps:
Step 1Create a “local.xml” file in your custom theme layout folder
Add the following content to the local.xml file
<?xml version="1.0" ?> <layout version="0.1.0"> <cms_page translate="label"> <reference name="root"> <remove name="breadcrumbs"/> </reference> </cms_page> </layout>
In order to optimize the performance of Magento websites it is recommended that you include only the relevant JS Or CSS files on a page. Generally all Magento websites have a slider on home page, so it is good idea to include the slider JS and CSS files only on the home page if none of the other web pages implement a slider.
You can use the following line to get the current store object.
// Get the current store $store = Mage::app()->getStore();
Below is the sample code showing you how you can access the store data. Two ways have been provided below to access the same data, you can use any one of them.
//Get the current store id $storeId = $store->getData('store_id'); $storeId = $store->getStoreId()); //Get the current store code $storeCode = $store->getData('code'); $storeCode = $store->getCode();
I was creating a child theme for a wordpress theme. I created style.css file in child theme which overrided some of the parent theme styles and a functions.php file which included the parent style.css as below:
<?php function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); ?>
Now when I activated the child theme from Wordpress admin, changes in the child theme were not reflecting. I checked the browser source code and found that the child style.css was included before the parent style.css.
$model->getOrigData() returns the data that was originally loaded from the database when you initialized the model object and called $model->load() method. After loading the model you may have performed certain updates to the $model object calling methods like $model->setData(). $model->getData() return the $model object data in the present state.
Magento models extend the class ‘Mage_Core_Model_Abstract’ which in turn extends the class ‘Varien_Object’. The methods getData() and getOrigData() have been defined in the class ‘Varien_Object’.
In Magento you can build a multilingual as well as a multi-currency website. In order to facilitate a multi-currency website, Magento asks you to setup [Admin >> System >> Configuration >> General >> Currency Setup] a ‘base currency’, a ‘default display currency’ and ‘allowed currencies’. The ‘base currency’ can be configured at global level or website level depending on your catalog settings at Admin >> System >> Configuration >> Catalog >> Catalog >> Price >> Catalog Price Scope while ‘default display currency’ and ‘allowed currencies’ can be configured at store view level.
Composer is a dependency management tool in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.
You must have PHP installed in your machine prior to installing “Composer”.
Composer requires PHP 5.3.2 or above (at least 5.3.4 recommended to avoid potential bugs).