// 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();
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
- start by cloning from master repo that has all magento versions (at least to the version you are currently using)
- get your clone and checkout new branch with the version you are currently using
- copy over your current site to this version
- 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
- 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
- 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
- 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
- if it is based on repo that has all versions you are in good condition (skip 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
- make a new branch of your current site used
- merge with new version
- disable all local, community extensions, turn on default theme, and upgrade
- enable theme, extensions one by one and debug where conflicts happen
It’s common to have a git setup like follows:
- MAGENTO MASTER -> REMOTE ORIGN THAT HAS ALL MAGENTO VERSIONS
- YOUR MASTER -> REMOTE ORIGIN IS MAGENTO MASTER
- 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://github.com/speedupmate/Magento-CE-Mirror.git yourprojectdir cd yourprojectdir git fetch --tags git tag git checkout -b yoursite_dev magento-18.104.22.168 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-22.214.171.124 //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 recommends you upgrade your installation using the following guidelines in a development or test environment, separate from your existing production environment:
- 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.
- In your current production environment:
- Back up your Magento database.
- Archive the file system.
This includes the media directory and subdirectories; all extensions and customizations; and all custom themes.
- In the development or test environment:
- Create a new, empty database instance.
- Import the production database tables into the development database instance.
- Copy your production media directory, extensions, themes, and other customizations to the development system.
- Copy local.xml to magento-install-dir/app/etc and edit it if necessary to reference the production database instance.
- In a web browser, go to your development system base URL.
- Wait for upgrade scripts to run.
- Verify the development system is now identical to the production system.
If not, fix issues, retest, and upgrade again.
- Test the development system thoroughly, including:
- Verify all extensions, themes, and customizations work.
- Place orders using all webstores and all payment methods.
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.
To get category’s URL by its ID use the following code
$category_id = 5; echo Mage::getModel("catalog/category")->load($category_id)->getUrl();
New version theme is not working in old version.
After upgrading magento or when I design theme in magento 126.96.36.199 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.
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…)
The following error (or similar) is shown in Magento Connect Manager on installation/upgrade:
ERROR: unable to unpack downloader/pearlib/download/AW_Blog-1.0.21.tgz
There is a bug in current stable PEAR/Archive_Tar implementation resulting in impossibility to unpack archives made by certain software versions.
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:
- navigate to System > Tools > Compilation page and click on Disable button:
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.