I can successfully updated the inventory qty in my custom module using the following lines of code. But the old value is still cached and displayed. I have already added
cacheable="false" in the
layout xml .
But it does not work. How to flush the cache after I have updated the value? What is the proper way to do this?
I now disable the full page cache for a workaround.
$stockItem = $this->stockRegistry->getStockItem($product->getId()); $stockItem->setData('qty',$qty-1); $stockItem->save(); $product->save();