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 »

Child theme stylesheet loading before the parent theme stylesheet

Wordpress

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.

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 »

What is the difference between ‘base_grand_total’ and ‘grand_total’ fields in ‘sales_flat_order’ table

Magento

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.

Continue reading »

Installing “Composer” – Dependency Manager for PHP in Windows

Composer

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).

Continue reading »

Create a new admin account in WordPress via FTP

Wordpress

If your Wordpress admin account get locked then you can try to restore admin account access by using the “Lost your password?” link on the admin login page or you can try to reset your password by directly updating it in database.

There is one more way if you have FTP access to your Wordpress installation folder. Guess How? By creating a new admin account.

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 »

Back to top