3

I spent a lot of time learning core concepts, and now I have a decent understanding of Magento 2.

However I am spending days, not hours, trying to make even tiny changes, like changing layout, I need to run and wait a lot of time whenever I make any changes to my website.

Commands like clearing cache,upgrading modules,deploying static content.

If you have missed one of these commands, you can spend a couple of days trying to find anerror in your code, but finally will find out that there are some generated files that are cached.

I am spending hours to change something in Magento 2that is done in seconds using other CMSes.

Whenever I make a change and it is not applied, I need to guess whether it is cached or I had made a mistake in my code.

Please suggest any way to speed up development time

  • Don't forget to turn off the browser caching in your browsere network tab, and don't forget that checkout uses local storage :) – vaso123 Jun 25 '18 at 11:42
  • Welcome to world of magento2 :) Sometimes a little thing is takes 2 days while I am debugging and find the entry point. – vaso123 Jun 25 '18 at 11:44
  • Magento development is highly complex and can be time consuming. It can do things no other CMS can, but simple things can be much harder to accomplish. Your frustration is justified. My suggestion is to spend some time familiarizing yourself with the steps required to see each type of change. Some require setup:upgrade but most only require cache:clean or even just resetting your browser cache. Once you know what to expect, you can either streamline you updates so you are running these processes less often, or at least spend less time trying to figure out if your change is broken. – jiheison Oct 20 at 15:47
  • @jiheison, I think it is misleading to say that it can do things no other CMS can, because that's just not true, – J. M. Becker Nov 26 at 21:34
  • I think it is true enough in the context of e-commerce development. But I'd be happy to learn otherwise, as I am no fan of Magento. I've worked with completely customizable CMS platforms that could technically do anything that Magento does, but it would be impractical to implement a Magento replacement. I think that is the main reason Magento continues to exist at all - path of least resistance. – jiheison Nov 26 at 22:03
2

It is good that you spent a lot of time learning core concepts. But if you still need to guess, which step is missing if something you made does not work, you should probably spend more time learning the following concepts:

  • static content deployment
  • code generation
  • caching
  • indexing

If you have a decent knowledge of these topics, it is usually kind of clear what you need to do so that your changes take effect. Start with the devdocs on these topics and google a bit for more information.

However, here are some general tips on speeding up Magento 2 development:

  • Enable all caches and use Mage2 TV Cache Clean. This tool clears only the required caches if you change specific stuff in your module. Hence, you more often have cache hits and you need to flush the cache manually much more rare.
  • Use the developer mode. This generally helps, because you see error messages, warnings etc. But it also leads to the fact that static content is deployed on the fly and that it is not copied, but symlinked from your module. Hence, if you change a static file in your module, you do not need to run static content deployment.
  • If you use integration tests (you should!), use the ReachDigital Magento 2 Performance tuned integration tests. It speeds up the boot time for the integration tests.
  • If you use integration tests (you should!), disable the TESTS_CLEANUP variable. This way, the database is not completely rebuilt on each integration test rebuild. The disadvantage is of course that you need to do that manually from time to time. However, it speeds up the whole process a lot.
  • Use test driven development (TDD). This way, you need to call the Magento 2 frontend / backend more rare.
  • (personal preference and dependent on your company) Develop on your local machine if possible. This way, you avoid all possible performance issues with tools like Docker.
  • I am not a frontend guy, but my frontend guy says that using grunt for the less compilation is much faster then the default compilation.
  • I am not a frontend guy, but use a tool like LiveReload. It automatically refreshes the browser on CSS / LESS / SASS changes.
  • I am not a frontend guy, but use the H&O Magento 2 Advanced Template Hints module.

I hope this helps a bit. I will try to update the post from time to time.

  • Even learning the core concepts and even knowing the codebase very well can't fix a system that requires the developer to fight against it to get things done. Your post makes it seem like there's some light at the end of the tunnel with m2. There is not. citation: 3 years on a m2 project. – Wolfe Nov 26 at 23:05
1

Magento2 takes 4x longer to develop for the only people that should consider it is large companies with a lot of money to throw at it, because that's the only way to get things done in it. It's just plain and simple, awfully designed. It still has bugs listed 3 years ago on it's github not resolved and there's over a thousand listed bugs at any time. Just pick something else.

  • 1
    Wise, I wish I had listened to this advice. Even large companies shouldn't use Magento though. – J. M. Becker Nov 26 at 21:36
0

I think your testing or learning in the local environment.

As you know Magento 2 is really massive.

My HDD upgraded to SSD (or RAM drive) for Magento files and database. After that Magento is fast to do setup:upgrade and content deployment.

So, I recommend to upgrade your HDD to SSD.

  • I agree with this. static:content:deploy for example generates a lot of files. Same with installing via composer. – Dominic Xigen Jun 17 at 17:22
0

maybe try looking into GRUNT WATCH for magento. Magento provides great docs on how to set it up: https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/css-topics/css_debug.html

  • I've found that grunt doesn't factor theme inheritance in some cases. In my experience this causes more problems that it solves. – Dominic Xigen May 12 at 21:11
0

I submitted a pull request which I believe made it into 2.3. You can use a GET param to enable/disable template hints. This helps speed up development in our team. Check the options under Stores –> Configuration. Select Developer option from the Advanced tab. Open Debug dropdown. Here you will find the options.

Under my pull request they did discuss backporting to 2.2 but I personally haven't got the time at the moment. Submitting a pull request to m2 git repo takes up a lot of your time.

0

In developer mode you don't need clean cache.

Change settings in backend Configuration => Developer => to Compilation on client side.

After some changes in less files you need clean pub/static/frontend/

Usually it fast process maybe your server is slow?

Update: local or cloud server - running developer mode + compilation on server side + all caches enabled and after any changes just

rm -rf var/cache/* var/page_cache/* var/session/* var/view_preprocessed/pub/static/* pub/static/frontend/* generated/code/

and refresh page (yes refresh can be slower)

  • When you modify xml you need to clean (flush) cache and no need to reindex. When you add or modify di, you need to recompile. – vaso123 Jun 25 '18 at 11:43
  • Ok , but you dont need recompile in developer mode. Plus is better to switch cache off by magento cache:disable. Still you need then clean sometimes some static files rm -R pub/static/frontend/* – BartZalas Jun 26 '18 at 0:50
  • Running a site in developer mode is painfully slow. As is running a site with all caches disabled. If doing frontend work I recommend disabling just the three. php bin/magento cache:disable layout block_html full_page – Dominic Xigen May 12 at 21:08
  • Its old answer, in my local or cloud server - running developer mode + compilation on server side + all caches enabled and after changes just rm -rf var/cache/* var/page_cache/* var/session/* var/view_preprocessed/pub/static/* pub/static/frontend/* generated/code/* Its extremally fast :) – BartZalas May 13 at 12:52
0

If you're in doubt whether there is an error in your code, please check the console. If the console doesn't display any error, then it may cache issues. So you have to flush or clean the cache.

Basically, Magento is slow by default compared to other platforms.

You may consider installing free plugins like lazyloading images and necessary configuration to speed up the Magento.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.