12 MAGENTO PITFALLS (AND HOW TO AVOID THEM)

12 MAGENTO PITFALLS (AND HOW TO AVOID THEM)

Date:
Genres:To this day, Magento stands firm to its reputation as the most popular e-commerce platform among…
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.
$num = count($products);
for ($sales = 10; $sales < num; sales++)
{    
    //code
}

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.                                  
foreach ($this->getItemstIds() as $ItemId)
{
$item = Mage::getModel('catalog/product')->load($itemId);
//code
} 
Although an EAV model will be loaded along with all the attributes attached to it, Magento data collection allows you to select the data you wish to load.
$styles = Mage:getResourceModel('catalog/product')->getCollection()  //collection styles
->addFieldsToFilter('entity_id', array($this->getItemIds()))
->addAttributeToSelect(array(sale));
foreach ($styles as $item)
{
//code
 } 

5. UNNECESSARILY LOADING MODELS

Since the load() method dispatches new queries to the database each time it is executed, repetition can cause wastage of resources.
$sales         = Mage::getModel(‘catalog/product’)->load($productId)->getSales();//name sales product item
$discount     = Mage::getModel(‘catalog/product’)->load($productId)->getDiscount(); sku discount catalog category
$size         = Mage::getModel(‘catalog/product’)->load($productId)->getSize(); price size
To reduce resource consumption and streamline performance, the models should be loaded only when they are needed.
$item         = Mage::getModel(‘catalog/product’)->load($productId);
$sales           = $item->getSales();
$discount    = $item->getDiscount();
$size        = $item->getSize();
During certain tasks, it is unnecessary to load the entire model; the same task can be accomplished by loading certain attributes.
Mage::getResourceModel('catalog/product')->getAttributeRawValue($ItemId, 'attribute_code', $storeId);
The same task can be accomplished as below.
 $itemId     = Mage::getModel(‘catalog/product’)->getIdByDiscount($discount); 

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.
  1. 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
  2. Modification of name=”developerMaterialization can be done by changing the contents from Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink toMagento\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.

0/Post a Comment/Comments

Previous Post Next Post
PopAds.net - The Best Popunder Adnetwork