Magento is among the most versatile and flexible eCommerce platforms. But it may not always be among the most rapid ones. Even if you’ve created an efficient store at the beginning, introducing more sections and products as the business grows may increase memory consumption and the load on the server. As a result, the loading speed drops.
Yet, it plays an important role in converting website traffic into paying customers. Whether you have an extensive product catalog or diverse payment options, prospects still expect the store to load fast. In fact, in one moment.
This rule applies not only to your product pages. Once consumers click the “Add to Cart” button, the response from the server should also come in the blink of an eye. If not, a shopper may try to hit the button several times, adding more items to the cart than needed. That isn’t very pleasant, at the very least. And let’s not forget that cart and checkout speed contribute to customer satisfaction and lower abandonment rates.
In this helpful guide, we’ll discuss some of the problems online merchants face with the Add to Cart action and how to speed up Magento.
Table of Content
Magento Performance: Key Considerations and Peculiarities
Over the years, the community managed to successfully combat the majority of Magento speed issues using a variety of tools. Most of the problems boil down to cache management, profiling, and manual bottleneck fixes.
When it comes to a store's speed issues, lots of developers are tempted to turn to caching to mitigate sudden performance drops. It's a common misconception even among developers, but cache almost never equals load speed. It's a great tool for dealing with other Magento inefficiencies, such as cache swelling and file fetching. But cache doesn’t make your whole store faster.
It's only used to facilitate website content delivery. And, of course, Magento doesn't cache the Shopping Cart (for obvious reasons). Magento 2 Add to Cart logic and Cart View itself both need to stay dynamic throughout the whole user experience.
Users need the ability to add or remove products from the cart at any time during shopping, apply promo codes, change the delivery or payment method, or in any other way, change your store content.
Slow Magento Add to Cart: What Can Go Wrong
Both Magento 1.x and Magento 2.x Add to Cart can be slow. Even though the platform doesn’t cache Cart contents or Add to Cart, the uncached content should still load in less than 1 second.
Why is your Magento Add to Cart very slow? To find out the real cause of the problem, you'll need to manually examine two possible bottlenecks: hosting and code. If you struggle with a lack of expertise, ourwill help.
Here is a list of the top reasons why something can go south:
- template inefficiencies;
- issues with third-party extensions;
- nonoptimal server configuration;
- inadequate resource allocation;
- unnecessary overheads.
Without a good tool to explore which call or function creates too much stress on the system, you won't understand what you need to fix in the first place. We've already shown youand . So, to learn what makes Magento 2.x and Magento 1.9 Add to Cart very slow, read on.
9 Tips on What to Do if Your Magento 2 Add to Cart Is Slow
Is your Magento Add to Cart slow? How can you speed up Magento 2 Add to Cart? In this article, we'll share nine recommendations to guide you through the process of making the Add to Cart faster on Magento.
1. Determine Which Part of the Store Creates the Bottleneck
In order to find the true bottleneck, you'll need to test the performance of different parts of the eCommerce website. By learning more about your underperforming parts, you’ll be able to create a detailed plan on where to direct your efforts. As a result, you’ll speed up Magento and, as a bonus, get the bestscore as well as improve your .
As you try to optimize slow Magento 2 Add to Cart and the overall Magento website speed, bear in mind the following thing. Web hosting infrastructure will determine the baseline of your store speed. Hardware plays a key role in creating the foundation of what you can expect from the Magento 2 store.
How can you tell if your real store suffers from underpowered hardware? Install default Magento with sample data and measure how well it performs. If the sample store runs poorly, then this is your bottleneck. Right here.
If you suspect that sample data doesn't reflect the current load on your store, generate more categories and products. Create as many new product pages and categories as you need to come as close as possible to the real-life setup of your store.
Depending on your exact needs, there are two solutions you can implement in Magento to speed up Add to Cart:
- upgrade to a better hosting plan (choose Magento-optimized servers if you can),
- fix your server configuration if the hardware is powerful enough already.
If you see that the demo Magento store runs well, then the issue is with the code. Depending on the reason, we'll need to fix the underlying issue. Start with profiling the Cart with the default Magento Profiler or run any profiler of your choice. Once you find the bottleneck, you'll need to deal with it. Here's a handyto get you started with the Profiler.
If you want to use something more capable, take a look at. It's a great alternative to the default tool and 100% worth a quick look.
Profiling works well if the bottleneck is in a database table, third-party extension, a few rogue scripts, or pieces of content. Working with the load table, you can sort the results by time to see which items have the biggest values in the fields Time and Cnt.
If you see that the store works fine and the problem is inside one of the extensions, switch them off on the test setup and then turn them on one by one to find those that slow your Magento 2 Cart the most. Profiling works best for this type of analysis, where you can rule out one item at a time and then move on to the next.
Here we've listed a few tips on how to make the shopping cart lighter without sacrificing too much.
2. Speed Up Inventory Management
To understand why the Add to Cart button can be very slow, you need to know what happens when the user clicks this button. Adding to Cart means Magento first has to check if the item is still available. This check is important to resolve possible conflicts when two or more users want to buy the same product with limited inventory.
The check happens within the Inventory Management section of the store, where Magento looks up item availability from a specific database table and then changes its value according to the user's actions in the store.
Okay, since now we understand the mechanism of the delay, we can do something about it. Two ways:
- speed up the database to shorten inventory lookup time,
- disable inventory management to boost Add to Cart performance (not a good idea unless your business sells thousands of identical items).
3. Disable the Carriers You Don't Use
Fetching carrier rates takes time. With the exception of Flat Rate and Free Shipping methods, the system needs to send a request to the carrier's server and fetch the response. The whole thing can take anything from 200 to 700 ms. The wait time quickly adds up to whole seconds your customers have to wait before they can act.
Removing the carriers you don't use is easy and can possibly shave off 1-2 seconds of the loading time without writing a single line of code. Go to Stores > Configuration > Sales > Delivery Methods and remove carriers you don’t work with.
4. Remove Estimated Shipping to Simplify Your Shopping Cart Page
Estimated Shipping is a good UX tool that helps you set customer expectations about pricing. Even so, if the shopping cart is too slow, you can push this information one step further – toward the checkout. This move will lift some burden off the server if your cart is overloaded with functionality and you can't balance it right.
for Magento 2 tell us that in order to customize the Checkout steps, you have to change checkout_index_index.xml (do it through custom module override, don't change Magento Core directly). In our case, we want to get rid of a specific Knockout component inside the cart shipping block.
According to DevDocs, you can disable Knockout components by passing the componentDisabled option into their config section using layout instructions. It looks like this:
<item name="%the_component_to_be_disabled%" xsi:type="array"> <item name="config" xsi:type="array"> <item name="componentDisabled" xsi:type="boolean">true</item> </item> </item>
For our needs, the instructions will be as follows:
<referenceBlock name="checkout.cart.shipping"> <arguments> <argument name="jsLayout" xsi:type="array"> <item name="components" xsi:type="array"> <item name="block-summary" xsi:type="array"> <!-- My custom part: --> <item name="config" xsi:type="array"> <item name="componentDisabled" xsi:type="boolean">true</item> </item> </item> </item> </argument> </arguments> </referenceBlock>
In addition to checkout_index_index.xml, you need to remove or comment on the following lines located in checkout/cart/shipping.phtml. Since it's a bad idea to directly change Magento internals, you need to override this template file in your custom module/theme and remove the lines there. Without this step, you'll still see the header of a now obsolete block:
<div class="title" data-role="title"> <strong id="block-shipping-heading" role="heading" aria-level="2"> <?php /* @escapeNotVerified */ echo $block->getQuote()->isVirtual() ? __('Estimate Tax') : __('Estimate Shipping and Tax') ?> </strong> </div>
All done? Good job. One less thing to worry about.
5. Disable Unused Shopping Cart Rules
It sounds obvious, but this tip offers a noticeable performance improvement. Apparently, Magento constantly checks for cart price rules before showing you the final amount. Naturally, a busy online store will have dozens of unused rules, which slow down Magento 2 cart and checkout speed.
Cleaning up all unused active rules offers a nice performance boost to both the Cart and Checkout. Just disable them, and you are done here. Make sure you flush the Magento cache to see the improvements.
6. Truncate Magento Database to Run Faster
Upgrading to acan massively help you out, but if you've done everything else here and still don't see improvement, look closely at your database. Over time, reading these massive databases and adding new entries becomes slower and slower. One of the solutions is to back up and truncate the tables. This solution works best for larger stores with millions of entries that don't hold a lot of value anymore.
Truncate and optimize the following database tables:
7. Optimize or Disable Extensions to Speed Up Magento Cart
Magento extensions that affect Add to Cart functionality, Magento shopping cart price rules, catalog rules, or add custom product options can severely slow down your Magento 2 Cart.
There are two approaches you can take here. The hard approach is to optimize thethat interferes with the Cart performance. Reviewing and refactoring code you have never seen before is not a trivial task, even for an experienced developer.
If you have the option, just turn off the unnecessary extension and look for alternatives that don't affect your cart performance as much. After all, this extension can't be the only one in the market.
8. Disable Minimum Advertised Price in Advanced Sales
Getting rid of complex cart price rules you don't use inside the store will help alleviate some pressure off the Shopping Cart. When the system doesn't need to check for an additional value in the database, this time can be spent on the actually important stuff.
One of these values people rarely use is MAP (Minimum Advertised Price). It's a vital feature for some stores that can't legally advertise a price lower than a price recommended by the manufacturer (commonly known as MSRP).
Anyway, most stores don't need this feature, and you can safely turn it off at Stores > Configuration > Sales > Sales.
9. Review All Add to Cart Events That Slow You Down
Let's return to the topic of profiling once again. You need to carefully examine what happens when the user clicks Add to Cart. Some slow-downs are easier to catch using New Relic, Blackfire, and similar performance monitoring applications than Magento Profiler.
For example, in one of our cases, a third-party analytics module sent curl requests upon adding new products to the Shopping Cart. As you might expect, this additional heavyweight cart event made the Magento 2 Add to Cart slow for the users.
Summing Up Magento Add-to-Cart Issues
While you are investigating your Cart performance, bear in mind that a slow Magento Add to Cart functionality can have multiple origins. Even if your cart is working smoothly, remember to set up a flow to reduce shopping cart abandonment and capture as many of those conversions as possible.
We’ve listed the 9 most general solutions we use to deal with Magento 2 Cart daily, whether you have slow Magento 1.9 Add to Cart or the same issue on newer Magento 2. We hope these tips will improve your operations and result in more sales. Even though these pieces of advice are quite effective, profiling Magento code for performance is the best way to find out bottlenecks and other speed issues, which will differ from site to site.
Implemented all our recommendations and still can't reach that <1-second performance mark on Magento 2 Add to Cart? Feel free to contact us for, and let's discuss how you can achieve better Cart performance with a talented team of professional eCommerce web developers.