Fix for Magento error Code already exists. in Sales > Tax > Manage Tax Rules, when saving the rule.
When trying to save Tax rules in Magento, you may get “Code already exists.” error if there are lots of tax rates passing in POST. Magento error is not making sense here, as the issue is something different. Basically when you post the data in PHP, it limits maximum post variables which should pass to the server. For me, that limit was 1000 in max_input_vars, which by changing to 20000 solved this issue and Magento successfully accepted my changes without any error.
To change max_input_vars to higher value, you need to edit in PHP.ini file for max_input_vars like this:
But as editing PHP.ini requires restarting apache to reflect the changes, I did the change in .htaccess file just for Tax rule modification and later reverted it.
You can edit .htaccess to make this change by copy-pasting below line at the end of the file:
php_value max_input_vars 20000
Now you should be able to change Tax rules even if you have lots of tax rates posting through for that change! I prefered to revert .htaccess back to what it was as I didn’t need to change tax rules frequently.
Note: If the above does not solve the issue for you, make sure your Tax Rule name is not duplicating with another tax rule name.
Magento read error on connection when using Redis. If you are using Redis as cache in Magento and read timeout is not specified, you may get this error. Below is how it looks in the error report.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
read error on connection Trace: #1 lib/Mage/Cache/Backend/Redis.php(210): Credis_Client->hGet('zc:k:0cd_FPC_DE...', 'd') #2 lib/Zend/Cache/Core.php(303): Mage_Cache_Backend_Redis->load('0cd_FPC_DESIGN_...', false) #3 lib/Varien/Cache/Core.php(158): Zend_Cache_Core->load('FPC_DESIGN_EXCE...', false, false) #4 app/code/core/Mage/Core/Model/Cache.php(379): Varien_Cache_Core->load('FPC_DESIGN_EXCE...') #5 app/code/core/Enterprise/PageCache/Model/Processor.php(185): Mage_Core_Model_Cache->load('FPC_DESIGN_EXCE...') #6 app/code/core/Enterprise/PageCache/Model/Processor.php(146): Enterprise_PageCache_Model_Processor->_getDesignPackage() #7 app/code/core/Enterprise/PageCache/Model/Processor.php(108): Enterprise_PageCache_Model_Processor->_createRequestIds() #8 app/code/core/Mage/Core/Model/Cache.php(703): Enterprise_PageCache_Model_Processor->__construct() #9 app/code/core/Mage/Core/Model/Cache.php(685): Mage_Core_Model_Cache->_getProcessor('Enterprise_Page...') #10 app/code/core/Mage/Core/Model/App.php(340): Mage_Core_Model_Cache->processRequest() #11 app/Mage.php(683): Mage_Core_Model_App->run(Array) #12 /var/www/source/index.php(87): Mage::run('', 'store')
The solution (atleast for us) was to add a read_timeout config option in app/etc/local.xml where you have configured Redis cache for Magento.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<cache> <backend>Mage_Cache_Backend_Redis</backend> <backend_options> <server>127.0.0.1</server> <port>6379</port> <persistent></persistent> <database>0</database> <password></password> <force_standalone>0</force_standalone> <connect_retries>1</connect_retries> <read_timeout>10</read_timeout><!--add this--> <lifetimelimit>57600</lifetimelimit> <compress_data>0</compress_data> </backend_options> </cache>
If your Magento products are not showing up in frontend category pages, that can be because one or more of the below points are not done correctly.
The products must have following set correctly to appear in the category pages in frontend. You can check all the below things in Manage Products screen of any individual product.
- Status must be Enabled (under General tab)
- Visiblility should be Catalog OR Catalog, Search (under General tab)
- Stock Qty (quantity) should be greater than Qty for Item’s Status to Become Out of Stock (under Inventory tab)
- Stock Availability must be IN STOCK
- Category should be assigned (under Categories tab)
- Website must be assigned (under Websites tab)
Clear the cache, re-index the indexes related to product (Product prices, Product flat data and Category products) and everything should work as expected.
This post is written to address the following issue:
magento products not displaying in categories
magento products not showing in categories
magento items not showing in categories
magento products not showing up in categories
magento products not showing under categories
magento products not displaying on category page
magento product images not showing in category
magento configurable product not showing in category
magento new product not showing in category
If you are unable to see Product Images in frontend category pages, check this blog post to resolve it: http://ka.lpe.sh/2013/02/26/magento-cant-see-product-images-in-category-page/
Magento gives 404 error / Forbidden error / Access denied error when you try to open the screen of your newly written config/system XML code because either of 2 reasons.
1.) You have written the code CORRECTLY, but Magento needs to write permissions for that module in session to show it.
- Just logout and login again and you should see your newly developed screen.
2.) You have some error in your ACL role code. Magento needs the ACL role information to allow admin view the admin module.
- Check your ACL code definition again and make sure everything there is correct.
Sample code of ACL to display custom menu item in navigation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<config> <acl> <resources> <all> <title>Allow everything</title> </all> <admin> <children> <mycustommenu translate="title" module="modulename"> <title>Custom MENU</title> <sort_order>500</sort_order> <children> <!-- child items go here --> <submenuitem translate="title" module="modulename"> <title>Custom SUB MENU</title> <sort_order>10</sort_order> </submenuitem> </children> </mycustommenu> </children> </admin> </resources> </acl> </config>
Magento Recoverable Error Argument 1 passed to Mage_Core_Model_Store::setWebsite() must be an instance of Mage_Core_Model_Website
Magento Recoverable Error: Argument 1 passed to Mage_Core_Model_Store::setWebsite() must be an instance of Mage_Core_Model_Website, null given, called in /var/www/xxx/app/code/core/Mage/Core/Model/App.php on line 634 and defined in /var/www/xxx/app/code/core/Mage/Core/Model/Store.php on line 395
When migrating Magento site from old server to new server, this error often occurs and appears in var/log/system.log. It prevents your Magento Admin to load JS and CSS files hence your admin panel becomes skinless.
The solution to get rid of this and load JS and CSS files is to run the following mysql commands in Mysql console or phpMyAdmin.
1 2 3 4 5 6
SET FOREIGN_KEY_CHECKS=0; UPDATE `core_store` SET store_id = 0 WHERE code='admin'; UPDATE `core_store_group` SET group_id = 0 WHERE name='Default'; UPDATE `core_website` SET website_id = 0 WHERE code='admin'; UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN'; SET FOREIGN_KEY_CHECKS=1;
What the above mysql commands does is:
- Disables foreign key checks on tables so that you don’t get any foreign key errors while executing immediate update queries.
- Updates store, store_group and website tables with ID = 0, for admin user
Once the above set of queries are executed, don’t forget to clear cache to reflect your changes.
Welcome to my Blog
- Apache (1)
- Domain name (3)
- eCommerce (2)
- Humor (3)
- Instagram API (1)
- jQuery (4)
- JSON (1)
- Linux (10)
- Magento (136)
- Magento admin (58)
- Magento Certification (2)
- Magento error (13)
- Magento frontend (68)
- Magento Interview (5)
- Magento2 (4)
- Mobile (1)
- MySQL (7)
- OroCRM (2)
- Performance (2)
- PHP (8)
- Prototype JS (3)
- Security (1)
- Wordpress (3)
- XML (2)