0

I'm seeing that everytime an order is placed, you have to refresh the cache manually, it displays the message on admin panel. In specific the configuration type cache. Is that normal?

I display an additional information on products like how many items are sold, so I need to resfresh the cache everytime an order is placed.

How can I do it?

0

There is no need to clean cache every-time, and sold item count on product view page doesn't create any problem, please clear cache with below command,

php bin/magento cache:clean
| improve this answer | |
  • Shows that error: [RuntimeException] The "--all" option does not exist. – slayerbleast Mar 29 '17 at 11:24
  • then can you please try without all and check on admin panel – Yogesh Mar 29 '17 at 11:32
  • yes of course it works.... but then when I place an order, it displays the message that I have to refresh the cache. That's actually the problem. Why I have to refresh the cache manually? – slayerbleast Mar 29 '17 at 12:20
0

Disable Asynchronous indexing.

In the backend go to:

Stores>Configuration>Advanced>Developer and at or near the bottom, you'll see "Grid Settings" and then disable "Asynchronous indexing".

Then clear your cache.

Your orders should now show in the admin Sales as soon as the order is placed. It drove me crazy for a while until I found the answer online.

| improve this answer | |
  • It's already disabled by system value :( – slayerbleast Mar 29 '17 at 16:18
0

The only solution I found was creating an observer, I don't think it's the best solution but I did not know what else to do.

etc/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="checkout_onepage_controller_success_action">
        <observer name="Vendor_Module_controller_success_action" instance="Vendor\Module\Observer\RefreshCache"  />
    </event>
</config>

Observer/RefreshCache.php

public function execute(Observer $observer)
{
    $result = exec('/usr/bin/php ' . BP . '/bin/magento cache:flush config');
}
| improve this answer | |

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.