Magento remove session id from URL
Magento displays session ID in url, something like:
http://loca.lho.st?__SID=2wewesfdgfsdm |
You can remove this in two ways:
1. Go to your Magento admin panel > System > Configuration > Web.
Under Session Validation Settings, set “No” against label “Use SID on the Frontend”.
If this doesn’t work, then move to option two below.
2. Edit the file at app/code/core/Mage/Core/Model/App.php (somewhere around line 222),
protected $_useSessionInUrl = true; |
Change that value to “false”. That should now prevent session IDs appearing in URL.
Magento Error: Fatal error: Call to a member function rewrite() on a non-object in app/code/core/Mage/Core/Controller/Varien/Front.php on line 165
Magento Error: Fatal error: Call to a member function rewrite() on a non-object in /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Front.php on line 165
While upgrading Magento from 1.7 to 1.8 version, this error generally appears and stops the site from loading.
We can get rid of this error simply by clearing the cache:
rm -rf var/cache/* |
If you don’t have terminal access, clear all the contents of var/cache/ directory.
Further if you have memcached or other caching system installed, flush them as well.
Magento remove reviews and ratings of products
Magento don’t provide admin screen where store owner can delete all the reviews and ratings of the products. The easiest way to delete them is using raw SQL queries, which you can run in Mysql console or in PhpMyAdmin. Remove/delete all the reviews and ratings of products in Magento using simple SQL queries given below.
truncate table `rating_option_vote`; | |
truncate table `rating_option_vote_aggregated`; | |
truncate table `review`; | |
truncate table `review_detail`; | |
truncate table `review_entity_summary`; | |
truncate table `review_store`; |
Magento debug XML (layout, config) files
In Magento if there is any error in XML file, Magento silently ignores it and continues further parsing. So you never get to know where is the actual error and makes it difficult to debug. You can’t even do any logging in XML file and also Magento don’t tell that error is in XML. It makes debugging almost impossible and ends up wasting in hours to find some silly mistake.
But we can know if there is any error in XML (layout.xml or config.xml or any xml file) if you use below code in the controller action which is being called. The browser will display WHOLE XML code and if it encounters any error in it, simply gives where is the error in the XML tree.
If you are trying to load let’s say Product View page, then put this code in Mage/Catalog/controllers/ProductController.php file’s viewAction() method temporarily to display whole XML tree to find out error(s) if any. As we are saying to display the page as XML, the page will break if it finds any mal-formed XML code and will show where is the mistake.
header("Content-Type: text/xml"); | |
echo Mage::app()->getConfig()->getNode()->asXml();exit; |
If you want to debug Layout Handles only, you can just check by this code:
header("Content-Type: text/xml"); | |
echo Mage::app()->getLayout()->getUpdate()->getHandles();exit; |
Magento delete empty categories and sub-categories
Remove all empty categories and sub-categories in Magento. When there are empty categories, the website shows empty page in those categories in frontend. Create a file in the magento root, I will name it rmvEmptyCats.php, with following code:
require "app/Mage.php"; | |
umask(0); | |
Mage::app(); | |
$categoryCollection = Mage::getModel('catalog/category')->getCollection() | |
->addFieldToFilter('level', array('gteq' => 2)); //greater than root category id | |
foreach($categoryCollection as $category) { | |
if ($category->getProductCount() === 0) { | |
$category->delete(); | |
} | |
} | |
echo 'Empty Categories Deleted!'; |
Now you can easily run it by navigating to http://loca.lho.st/rmvEmptyCats.php and wait for the message Empty Categories Deleted!
Note that this is going to DELETE those categories with zero product count.
Welcome to my Blog
Certifications
Honor
Recognition
Contributions
Categories
- Apache (2)
- ChatGPT (1)
- Domain name (2)
- eCommerce (2)
- htaccess (1)
- Humor (3)
- Instagram API (1)
- jQuery (4)
- JSON (1)
- Linux (10)
- Magento (142)
- Magento admin (58)
- Magento Certification (5)
- Magento error (13)
- Magento frontend (68)
- Magento Imagine (2)
- Magento Interview (5)
- Magento Master (2)
- Magento2 (10)
- Mobile (1)
- MySQL (7)
- OpenAI (1)
- OroCRM (2)
- Performance (2)
- PHP (8)
- Prototype JS (3)
- Security (4)
- Wordpress (3)
- XML (2)