Tag » Posts Tagged ‘Magento 1.x’

How to remove breadcrumb from a page in Magento

Magento

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>

Continue reading »

How to add a JS or CSS file only on Home page in Magento

Magento

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.

Continue reading »

Get the current store details like store code, name, status, currency etc.

Magento

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();

Continue reading »

What is the difference between $model->getData() and $model->getOrigData(); methods in Magento?

Magento

$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’.

Continue reading »

How to add sorting option – “Sort by Date” in Magento

Sorting

You may want to provide a sorting option “Creation Date” so that customers can easily find the newest and the oldest items.

To do so extend the class “Mage_Catalog_Model_Config” located at {{MAGENTO_ROOT}}/app/code/core/Mage/Catalog/Model/Config.php in a custom module and override the function “getAttributeUsedForSortByArray()”

Continue reading »

How to enable/disable the demo store notice in Magento

Magento

Magento provides a configuration option to help you show a demo store notice when your web store is not yet live and you are just running a demo store.

To enable/disable the demo store notice:

  • Log into the Magento Admin
  • Navigate to System >> Configuration
  • Select the Design Section

Continue reading »

How to enable compilation in Magento using the command line tool

Compile

The compiler in Magento makes a copy of every class used by the Magento system in the directory “includes/src” using the full class name as the filename. Thus, Magento Autoloader has to look only in the directory “includes/src” instead of traversing multiple paths.

Magento ships with a command line script “compiler.php” located in the shell directory present at the {{MAGENTO_ROOT}} of you installation.

Continue reading »

How to enable compilation in Magento

Compile

The “Compilation” tool in Magento was introduced to give a performance boost to the Magento website. Complation tool does not convert Magento PHP code to Bytecode but what it does is that it concatenates various PHP files into larger files and stores them in a single location “includes/src”. So now the Autoloader has to look in includes/src and will open less files. Without Compliation enabled the Autoloader has to check app/code/local folder, app/code/community, app/code/core and finally lib in sequence in order to load a class.

Continue reading »

Changing the “Position” text to “Default” in the “Sort By” dropdown on product listing page in Magento

Magento

In Magento Vanilla installation the products are sorted based on “Position” on the product listing page by default. You have the provision to configure the default sorting parameter from Magento admin. In Magento Vanilla installation admin the options available are – “Best Value”, “Name” and “Price”. “Best Value” sorting is actually sorting by position.

“name” and “price” are catalog attributes but “position” is not.

If in case you need to remove sorting by position then you will have to override the Catalog module model but if just you need to change the text then you can do it with the help of locale files.

Continue reading »

How to change the default sorting on product listing page in Magento?

Listing

In Magento you can change the default sorting attribute for product listing page from Magento admin.

To set the sorting attribute login to Magento admin and follow the following steps:

1. Go to Admin >> System >> Configuration >> Catalog
2. Expand the “Frontend” Section
3. Make selection from the “Product Listing Sort by” dropdown
4. Click the “Save Config” button.

Continue reading »

Back to top