Answer the question
In order to leave comments, you need to log in
The CatalogProvider getProductData method is not called. Why?
The rule for working in the basket is not suitable, because data is changeable (item ID).
It is necessary that when adding a product to a position there was a discount, depending on certain conditions.
How to implement the discount functionality correctly?
I tried using CATALOG_PROVIDER_CLASS, but this method does not work.
I provide the code below:
namespace My;
use \Bitrix\Main\Diag\Debug;
class MyCatalogProvider extends \Bitrix\Catalog\Product\CatalogProvider
{
public function getProductData(array $arParams)
{
self::log($arParams, 'logs/_catalogpriceprovider.log');
}
public static function log($var, $path = 'logs/dump.log', $varName='')
{
Debug::dumpToFile($var, $varName, $path);
}
}
// ....
$arFields = [
'PRODUCT_ID' => (int)$id,
'QUANTITY' => (int)$quantity,
// 'PRICE' => $arPriceOptimal['RESULT_PRICE']['BASE_PRICE'] - $arPriceOptimal['RESULT_PRICE']['DISCOUNT_PRICE'],
// 'CURRENCY' => $arPriceOptimal['RESULT_PRICE']['CURRENCY'],
'CATALOG_PROVIDER_CLASS' => '\\My\\MyCatalogProvider'
];
$rs = \Bitrix\Catalog\Product\Basket::addProductToBasket(self::getBasketForCurrentFUser(), $arFields, ['SITE_ID' => 's3']);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question