Magento 2 Extension Development : Commonly Faced Issues & How To Troubleshoot Them

November 9, 2019 in Biohacking

Recently I was asked to develop a mage 2 Shipping extension. I am basically a JavaScript developer and working in PHP with class heavy framework like Zend was hard battle initially.

In this process I learnt a lot on what not to do or to consider. I would like to share my knowledge on the same.

Biggest thing to consider is the case of Module Name, Folder Name, Class Name etc.

Starting with Naming

The module name can be comprise of any number of worlds but only the first letter should be capital.

eg: if the module is on generating shipping label then name should be “Generatingshippinglabel”. Any other combination will cause issue in different platform like

GeneratingShippingLabel

.

In case of Folder Name, Class Name it should CamelCase i.e

GeneratingShippingLabel

.

Cache

Yes, cache…

Magento pages starts slow as it needs to cache all the data during the initial load. As the page loads all the XML and other configuration will be cached. And yes, XML configuration will not be updated even if you update in XML after caching.

The one and only solution is to clear cache.

php ./bin/magento cache:clean
php ./bin/magento cache:flush

What to do when new class are added but not working?

The solution to most of the problem in Magento 2 is

php bin/magento setup:di:compile

This will generate Interceptors Class. Yes, Interceptors Class, in this process all dependency will be injected, also your whole code base will be compiled and throws any error.

Next thing to do after this is clean cache.

But sometimes cache will not be deleted due some timeout issue. This you can check in system.log @ var/log/system.log. After you run above commands error will be logged in system log if any. In this case blindly remove “var/cache”

These are some issue I faced while developing the module. Will update this article as find more until next time happy coding.

Also, let me know if I have missed any important topic.

Source link

Leave a reply

You must be logged in to post a comment.

Skip to toolbar