1

In a Magento 2.2.6 installation we have the following configurable product for example:

products

The product with ID 3502 has the products with IDs 3503 and 3504 as its configurable options. All products have a price assigned.

However, when I load a product collection via

$products = $this->productCollectionFactory->create()
                 ->addWebsiteFilter($store->getWebsiteId())
                 ->setStore($store)
                 ->addAttributeToSelect('*');

and then iterate over the collection and use

$product->getFinalPrice();

the function always resturns 0.00 for the product with ID 3502 - it should be 261.84 of course.

It does work for other configurable products, but not for some. So far I have no clue why it would not work for this particular product for instance.

I also checked the flat tables and made sure they are properly indexed.

May be someone has any pointers on why Magento could possibly return 0.00 for these products for their "final price".

  • check the price value in particular store.. I believe in that store it should be 0.00 – Vigna S Jan 21 at 11:14
  • Good point, but I have checked that too. The prices are not overridden for the particular store. Only the 'default config' is used. – fritzmg Jan 21 at 11:59
0

Try calling addPriceData on the collection:

$products = $this->productCollectionFactory->create()
             ->addWebsiteFilter($store->getWebsiteId())
             ->setStore($store)
             ->addAttributeToSelect('*')
             ->addPriceData();
0

The problem was caused by an inconsistency in the database. As you can see in the screenshot, the base product displayed a price - but there shouldn't be any price displayed there for a configurable product. After editing and saving the configurable product again, everything worked.

The data for these products was migrated from a Magento 1.x installation. As far as I know, in Magento 1.x you had to set a price for the base product and the configured products only added to that price. I assume that during migration the price for the base product wasn't properly reset.

  • 1
    Oh yeah... Make sure you cleanup the prices and special prices and msrp and any other price type attribtues directly linked to the configurable products. – Marius Jan 21 at 12:50

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.