Magento Adminhtml and Relative Links to Static Resources

Relative links in URLs allow you to only specify the path to an resource that is in the same or subfolder of the current folder. Lets say the current page you are on is http://example.com/test/ and you want to reference an image at http://example.com/test/image.jpg. You could put the full http://example.com/test/image.jpg in the src attribute of the img tag, or you could use just image.jpg instead. This works well when you are not sure what the directory path is the parent directory of your code. However, it can cause some issues when your code is moved to another location, but some resources are not moved, such as image.jpg.

Magento Adminhtml

Magento’s Adminhtml, or administration backend goes through a completely different route in the app/Mage.php code to enable you to control the menu, products, and content of your site, among other things. Many eCommerce sites using Magento need some aspect of the administration backend customized to handle the unique workflow for the business. However, there are some occasions where this can cause some unintended consequences.

When customizing the administration backend for Magento, there are some cases where you may need to include a third party library to achieve the desired result. One thing that many of these libraries do is reference all of their resources with relative links. If, in the process of including the third party library, you neglect to include the resources referenced in the JavaScript or CSS, then it will cause a 404 error to occur when accessing the resources.

When you factor in that only the URLs that are configured for the administration backend load the backend code, and all others, including 404 not found errors load the frontend code and error pages to help your users find their way, you may start to see some performance issues. I have seen some sites with two such resources with 404 errors attempt to be loaded on every administration backend page load. Not only does it cause the web server to load all of the frontentd .phtml files necessary to display the 404 error page, but it also incurs all the same database access calls that are required as well. When accessing the administration backend of this particular site with the 404 resources included, there is a definite delay in the loading of the page. Simply removing the references to these resources that do not exist or correcting these refereces makes the page load extremely quickly, as one would expect.

comments powered by Disqus

Related Posts

MySQL Deadlocks with Magento

One of the things that Magento, and specifically the Zend Framework provide developers is the ability to not have to think about database details as it should just handle all that for you. When it becomes obvious that there is a problem somehow with the production database getting some sort of SQL errors, its time for the developers to start caring about the implementation and architecture details of the database.

Read More

Login Problems with Magento and Varnish

When you have a Magento website configured to use Varnish as a caching frontend, there are certain scenarios where you may have some problems logging-in to the frontend of the website. It poses some unique problems that are not frequently seen on a typical website. This issue typically manifests itself to the end user by visiting the login page, entering the correct credential, submitting the form, and then the page reloads the login page again instead of redirecting to the My Account page or whatever page is specified in the configuration.

Read More

Creating a Best-Sellers Category with Magento

Magento allows you to organize products in categories, and a single product can be a member of quite a few separate categories. As a result, you can create a category that is specifically for your top selling products. You could manually keep track of which products sell the best, either by number of sales completed, or by the actual quantity of each product that were sold. If you want to spend all your time managing this category, then this is the way to go.

Read More