If I try to print price
and final_price
from $_product
in category page template (product/list.phtml
), they have the same value despite the product is affected by a catalog rule.
Why?
How can I get the discounted price in there?
Make sure your price indexes (actually all your indexes) are up to date.
The prices in the product list don't come directly from the product entity. They come from the table catalog_product_index_price
where the indexed prices are kept.
If you have a discount rule that you just created but you did not rebuild the indexes you won't see the proper prices in the list.
This does not apply to the product view page because here the prices come from the product entity directly.
catalog_product_index_price
they are the same. You're right. I've tried to update all my indexes (php bin/magento indexer:reindex
) but nothing's changed.
final_price
didn't changed. I'm not using varnish.. I'm developing in a local environment.
ListProduct
in list.phtml
) in this way: $this->_productRepository->getById($id);
I don't found final_price
attribute..