Magento – Get Current Store Details (ID, Code, Name and Status)

Magento – Get Current Store Details (ID, Code, Name and Status)

// Gets the current store’s details
$store = Mage::app()->getStore();

// Gets the current store’s id
$storeId = Mage::app()->getStore()->getStoreId();

// Gets the current store’s code
$storeCode = Mage::app()->getStore()->getCode();

// Gets the current website’s id
$websiteId = Mage::app()->getStore()->getWebsiteId();

// Gets the current store’s group id
$storeGroupId = Mage::app()->getStore()->getGroupId();

// Gets the current store’s name
$storeName = Mage::app()->getStore()->getName();

// Gets the current store’s sort order
$storeSortOrder = Mage::app()->getStore()->getSortOrder();

// Gets the current store’s status
$storeIsActive = Mage::app()->getStore()->getIsActive();

// Gets the current store’s locale
$storeLocaleCode = Mage::app()->getStore()->getLocaleCode();

// Gets the current store’s home url
$storeHomeUrl = Mage::app()->getStore()->getHomeUrl();

Magento upgrading with Git


It’s rather easy but you have to ensure that your site is based on some master repo that can be merged down the stream with earlier versions (repo that has all Magento versions as tags or branches that can be merged to latest from first). So here’s two scenarios to follow

1. My site is not in git

  1. start by cloning from master repo that has all magento versions (at least to the version you are currently using)
  2. get your clone and checkout new branch with the version you are currently using
  3. copy over your current site to this version
  4. after that done “git status” will show you the diff with original version you started with and all the edits you have made to it
  5. its now smart to move all core edits to local codepool and revert any changes in core to original files, move any edts in default or base templates to your own template and revert changes in default or base template files. Same goes with all the files that look modified against the original version. This gives you “all my changes are separate from original code and they will not conflict my upgrades”, it’s wise to commit this state
  6. If all things are separated from original files then it’s time to upgrade. Turn on default theme, disable all local and community extensions , merge the new version with your current branch. Visit the site to perform the upgrade
  7. Now your site is upgraded and you can turn on your theme and custom extensions one by one to see what is compatible and what not. Debug and solve one by one

My site is already in git

  1. if it is based on repo that has all versions you are in good condition (skip 2)
  2. if it’s not then you can add some repo that has it all as your remote and start with merging your current version and separating changes from original like described in first scenario
  3. make a new branch of your current site used
  4. merge with new version
  5. disable all local, community extensions, turn on default theme, and upgrade
  6. enable theme, extensions one by one and debug where conflicts happen

It’s common to have a git setup like follows:

    • branch: yoursite_dev
    • branch: yoursite_stage
    • branch: yoursite_live

You always develop on your_dev branch andif changes are ready for evaluation you merge _stage with _dev and if changes are approved you merge the state to _live either from _dev or from _stage.

commands based on theoretical endpoints

git clone git:// yourprojectdir
cd yourprojectdir
git fetch --tags
git tag
git checkout -b yoursite_dev magento-
git checkout -b yoursite_stage yoursite_dev
git checkout -b yoursite_live yoursite_dev
git checkout yoursite_dev
git branch
//copy in your site
//separate changes or originals
//add any file/dir with local importance to .gitignore
//turn of your default theme, disable all local/community extensions and overrides
//assuming you are on dev branch commit your clean state
git merge magento-
//visit the site to execute the upgrade
//enable your theme , extensions , debug

this gives you a starting point for scenario 1 and after that you could just copy in your site and start separating changes and making order in your current site and themes.


Magento: How to Upgrade Magento community to 1.8

How to Upgrade Magento community to 1.8

How to Upgrade Magento community to 1.8

Magento recommends you upgrade your installation using the following guidelines in a development or test environment, separate from your existing production environment:

  1. Create a parallel development or testing system, identical to your current production system.
    You’ll use this parallel system to implement and test the Magento upgrade.
  2. In your current production environment:
    1. Back up your Magento database.
    2. Archive the file system.
      This includes the media directory and subdirectories; all extensions and customizations; and all custom themes.
  3. In the development or test environment:
    1. Create a new, empty database instance.
    2. Import the production database tables into the development database instance.
    3. Copy your production media directory, extensions, themes, and other customizations to the development system.
    4. Copy local.xml to magento-install-dir/app/etc and edit it if necessary to reference the production database instance.
    5. In a web browser, go to your development system base URL.
    6. Wait for upgrade scripts to run.
    7. Verify the development system is now identical to the production system.
      If not, fix issues, retest, and upgrade again.
  4. Test the development system thoroughly, including:
    • Verify all extensions, themes, and customizations work.
    • Place orders using all webstores and all payment methods.

Magento: Move a category programmatically

It turns out that Magento has some really convenient functions already made at its core, which i don’t know about and this is one of them. Mage category model object includes move() function, that manages just that. Lets view simple code example for better understanding.

$categoryId = 2269;
$parentId = 2268;

$category = Mage::getModel('catalog/category')->load($categoryId);
$category->move($parentId, null);

When this is executed your category should have a different path, if changes are not visible than try to clean cache and reindex data. After you have done that everything should be ok.

Magento Invalid Method Mage Catalog Model Product IsDuplicable

Magento Invalid Method Mage Catalog Model Product IsDuplicable

Magento Invalid Method Mage Catalog Model Product IsDuplicable

New version theme is not working in old version.

After upgrading magento or when I design theme in magento and use that theme in magento 1.4.2 that time my product page shows error like
Invalid method Mage_Catalog_Model_Product::isDuplicable

I find the solutin and its work for me.

Copy your product.php file from this path: app\code\core\Mage\Catalog\Model\product.php and replace in your maegnto folder.

Magento AddAttributeToFilter SQL Conditionals

Magento AddAttributeToFilter SQL Conditionals

Magento AddAttributeToFilter SQL Conditionals

If you want to customize query or product collection data you can easily to do that with addAttributeToFilter funcation in magento. In short you can easily customize product collection select query based on your requirement in magento development.

<?php $collection = Mage::getModel('catalog/product')->getCollection(); ?>

If you want get all fields then use below condition select (more…)

Magento: How do I disable Magento Compiler?

Magento Compiler feature should be disabled on any changes in loaded Magento classes, in other words, you need to disable Magento Compilation every time before installing new extension or initiating upgrade/downgrade/installation or removal of any Magento module.

To disable Magento Compiler you can use one of the following methods:

Admin Interface

  • navigate to System > Tools > Compilation page and click on Disable button:

How do I disable Magento Compiler?

How do I disable Magento Compiler?


Magento: Fixing Magento Category Order Problems

Fixing Magento Category Order Problems

Fixing Magento Category Order Problems

Recently, one of our clients could not get their product categories to appear in the order set in the Magento Catalog > Manage Categories screen. No matter how they dragged and dropped the categories, the ones near the top would not display as intended on the front end.

How Magento Orders Categories

Categories are displayed in navigation menus based on a field titled “position” in thecatalog_category_entity data table. By default, the order is displayed in ascending order. There are other ways of adding code to display categories alphabetically, but by default, the order shown is determined by the position value.

So, why would changing the order under Manage Categories not work?

What I Observed

When working in the Manage Categories menu, the client and I were focused on manipulating the top 2-3 categories, as those were the ones most important to him at the time. We could change their order, but even after re-indexing the Flat Catalog, the front end would still not display the correct order.