opengento / module-minimal-price
This extension allows to set if a product is minimalPrice and can show its price by scope and customer group.
Fund package maintenance!
www.helloasso.com/associations/opengento/formulaires/1
Installs: 110
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 7
Forks: 1
Open Issues: 0
Type:magento2-module
Requires
- php: ^8.1
- magento/framework: *
- magento/module-catalog: *
- magento/module-catalog-rule: *
- magento/module-eav: *
Requires (Dev)
- magento/magento-coding-standard: ^33
- roave/security-advisories: dev-latest
README
This extension allows to set a minimal price to a product (MAP).
Setup
Magento 2 Open Source or Commerce edition is required.
Composer installation
Run the following composer command:
composer require opengento/module-minimal-price
Setup the module
Run the following magento command:
bin/magento setup:upgrade
If you are in production mode, do not forget to recompile and redeploy the static resources.
Features
Define the minimal price availability for a product. The price is capped to the minimal value if any special price, tier price or catalog rule tries to price down the limit.
Product Attributes
minimal_price
, available in the "Advanced Pricing" group.
If you use the native import export tool provided with Magento, the attribute minimal_price
is mapped with the field map_price
.
Did You Know
An hiding an never completed feature
While working on this project, it appears that Magento already has an attribute with code "minimal_price".
This attribute exists in Magento since forever. It's actually a system attribute which is not visible through the admin panel.
There is also a few method that refers to this attribute, such as:
- \Magento\Catalog\Model\Product::getMinimalPrice (Called in \Magento\Catalog\Pricing\Price\FinalPrice::getMinimalPrice)
- \Magento\Catalog\Model\ResourceModel\Product\Collection::joinMinimalPrice (Never called)
This attribute and methods are not used in the Commerce edition neither.
There is also some trace there: \Magento\CatalogImportExport\Model\Export\Product
:
...
'minimal_price' => 'map_price',
'msrp' => 'msrp_price',
'msrp_enabled' => 'map_enabled',
...
This suggests that minimal_price
is mapped as "Minimum Advertised Price" (MAP). MAP policies are legal documents brands
use to define the lowest legally possible advertised price for a product. It does set the minimum, some penalties may be
applied if a seller violates the MAP.
This module updates and reuse this existing attribute in order to give it a true usage.
Price Indexer, to be or not to be?
Also, while investigating a bug where the minimal price value was not handled in the PDP nor PLP.
It seems that the catalog_product_index_price is not used to render and display the final prices.
When inspecting the query logs, it seems that even if the indexer is loaded and applied to the product list,
when the template render the prices, the following method is used \Magento\Catalog\Block\Product\ListProduct::getProductPrice
.
This method calls Magento\Framework\Pricing\Render::render
which render a price by code. The engine will proceed with
Magento\Catalog\Pricing\Price\FinalPrice
and Magento\Catalog\Pricing\Price\BasePrice
. The rendering is finally delegated
to Magento\CatalogRule\Pricing\Price\CatalogRulePrice
which loads any active catalog rules.
The performance struggles comes when you have a lot of active catalog rule loaded every team for each items on the page.
Support
Raise a new request to the issue tracker.
Authors
License
This project is licensed under the MIT License - see the LICENSE details.
That's all folks!