The pricing bundle is the kernel of management of price system for OroCommerce B2B . In frontend the price get showed by system layout based on service :
oro_pricing.layout.data_provider.frontend_product_prices: class: 'Oro\Bundle\PricingBundle\Layout\DataProvider\FrontendProductPricesProvider' arguments: - '@oro_pricing.model.product_price_scope_criteria_request_handler' - '@oro_product.provider.product_variant_availability_provider' - '@oro_pricing.user_currency_manager' - '@oro_pricing.formatter.product_price_formatter' - '@oro_pricing.provider.product_price' tags: - { name: layout.data_provider, alias: frontend_product_prices }
This service is layout provider which give you the ability to get price list of specific product , the process of rendering price for top selling products fro example starts by importing oro_product_list which import oro_product_list_item so to customization of this path you can find :
vendor/oro/commerce/src/Oro/Bundle/PricingBundle/Resources/views/layouts/blank/imports/oro_product_list_item/price.yml which contain:
layout: imports: - id: oro_product_price root: __product_secondary_content_first_container actions: []
is responsible to render the price of every item on to selling if you go to explore oro_product_price you will find the content:
layout: actions: - '@setBlockTheme': themes: 'OroPricingBundle:layouts:blank/imports/oro_product_price/oro_product_price.html.twig' - '@addTree': items: __product_price_container: blockType: product_prices options: productPrices: '=product ? data["frontend_product_prices"].getByProduct(product) : []' attributeFamily: '=context.offsetExists("attribute_family") ? context["attribute_family"] : null' isPriceUnitsVisible: '=product ? data["oro_price_unit_visibility"].isPriceUnitsVisibleByProduct(product) : true'
So you can now explore that layout provider frontend_product_prices used to get price list of the current item :
productPrices: '=product ? data["frontend_product_prices"].getByProduct(product) : []'
if you go to class Oro\Bundle\PricingBundle\Layout\DataProvider\FrontendProductPricesProvider and explore the function :
public function getByProducts($products) { $this->prepareAndSetProductsPrices($products); $productPrices = []; foreach ($products as $product) { $productId = $product->getId(); if ($this->productPrices[$productId]) { $productPrices[$productId] = $this->getProductPrices($productId); } } return $productPrices; }
You get the combined price list of current product.
Video about subject
Comments