12 Magento Pitfalls (and How to Avoid Them)

To this day, Magento stands firm to its reputation as the most popular e-commerce platform among online businesses. From startups, SME’s to large scale corporations, this orange shopping cart has been knighted as “The People’s Favorite”.

Be it brands like Nike, Nestle, Fox Connect, Samsung, Ford, Lenovo, Olympus, Vizio and Men’s Health, or other millions of eStores, Magento’s foothold in the e-commerce landscape has accelerated and reached new heights.

We’ve been very frustrated with the state of open-source eCommerce we knew it could be done better

Roy Rubin, Co Founder/CEO Magento

What Makes Magento so Special?

With its thousands of elegant themes, open source extensions and a mighty community always in for action, Magento presents itself as the best option for a reliable, fast and user-friendly eStore with the best practical features for online commerce. However, in order to tame this orange beast, developers must acquire a fair knowledge on the most common pitfalls to avoid, and fix.

Technical issues often arise during the deployment phase, which can not only compromise website performance, but lead developers into blaming the platform rather than debugging to identify the exact cause of the issue. The following 12 are the most common issues encountered during Magento deployment and we have provided their simplified solutions alongside them.

1. Changing Main Magento Files

Modifying the main Magento files always leads to issues in later stages, whether during updates or integrating new extensions. Although additional code can be added to the main Magento files through <rewrite>, modifying it again can create an extends chain which complicates the entire program and results in errors when one or more modules are disabled or removed. However, multiple modules can access the same event without causing errors through event observers.

2. Unnecessary Load on Memory

The fetchAll() method consumes a major portion of memory and network resources when it has to retrieve heavy amounts of data. Under most cases the entire data set is unnecessary; coding the fetch() method to retrieve rows from database disjointedly achieves better results.

3. Use count() Method Warily

Count() is useful but can also potentially become a burden on memory resources if utilized within loops. This is because it calculates the length of array it is assigned to for every iteration. In case the array happens to be a lengthy one, the time required for count will ultimately slow down your processing.

for ($sales=10; $sales < count($products); sales++){//code}

If the size could be determined outside looping condition from the start in such manner as below, the program can be streamlined for memory efficiency.

4. Nesting SQL Queries within Looping Conditions

SQL queries already consume considerable memory and network resources, and looping them results in an even more resource demanding process. For example, a single Entity Attribute Value (EAV) model demands a sizable chunk of resources and since an online store features numerous products and services, such coding will ultimately consume excessive time.

6. Avoid Router Issues

You can eliminate router issues by ensuring that similar names are assigned for both frontend and admin routers. Taking out router issues is imperative as it directly interferes with behavior of modules. In case the module functions without an admin router, remove it entirely, as it may cause issues such as failure to detect frontend page or redirecting to HTTPS from HTTP.

7. Exception Handling

Exception handling is the perfect solution for containing any unexpected behavior the code may display due to any reason. Errors can be checked safely in staging servers but once it goes live, unknown errors cause the online store to behave erratically that may lead to user abandonment. Using try-catch blocks guarantees the module will continue operating even when it encounters unpredictable errors which keep the website to its optimum performance.

8. Updating Security

Magento has a reputation of timely releases of security updates when a new version surfaces or when they detect a breach in their code. Either way, updating your e-commerce store security enhances the security protocols and prevents your valuable data from being stolen and misused. Since the updates are designed by the recent software releases and advancements in hacking techniques, updating safeguards your Magento store from spam ware and third party cyber-attacks.

9. Common Extension Installation Mistakes

One another amongst the notorious issues faced while deploying Magento is extension integration and installation. The developer must download the correct extension compatible with the Magento version in use after verifying system requirements. Each step must be followed correctly as provided in the extension installation guideline.

Also, the statics cache must be cleaned to start using the extension. Cleaning cache is easy. Go to System > Cache Management > Flush Static Files Cache. This also applies for static content cache each time any change in setting or extension is made. This prevents old CSS files from interfering with the front end’s performance. Extensions play an integral role during deployment and making errors during these stages can be catastrophic for your online store. To make sure your extension works uninterrupted in the best means possible, test their functionality after downloading to avoid a clash with other installed extensions. Last but not the least, double check if the download file path is in the correct folder.

10. Using FTP to download Magento

Installing the complete version of Magento via FTP can cause numerous issues during updates. For best results, developers are recommended to use the downloader provided by Magento so any such errors can be avoided. It is both user-friendly and allows user to select the files which they wish to download. This significantly helps in streamlining the entire process of Magento re-installation.

11. What to do with 404 error for CSS and scripts

Another common issue developers face is the creation of symlinks. The production of symlinks in not by random nature, but to suffice static resources. Developers can fix this by the following simple steps.

You can start by finding virtualType name=”developerMaterialization” after opening app/etc/di.xml. Once you have located it, you will come across an item name=”view_preprocessed.” You can either delete it or set it for modification.

When deleting them, be careful not to alter or erase the .htaccess. To get rid of any existing symlinks, Delete the files under pub/static

Modification of name=”developerMaterialization can be done by changing the contents from Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink to Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

12.Layered Navigation Management

While Magento does provide a well-defined layered navigation system, its success highly depends on how this functionality is integrated. Layered navigation can exhibit duplicate content which can negatively impact on SERPs. To avoid this, AJAX or cookies can be used to disable search engines from accessing the layered navigation content, only permitting customers to view it.

Final Thoughts

Magento is a robust e-commerce platform rich with user-friendly features and world-class functionalities.Using such a dominant ecommerce platform to its full spectrum means acquiring a thorough understanding of its do’s and don’ts.