E
E
Evgeny Nikolaev2019-06-27 11:47:40
1C-Bitrix
Evgeny Nikolaev, 2019-06-27 11:47:40

The sale repeats the complex component catalog bitrix. How to set up an array in FILTER_NAME so that only discounted products are displayed on the sale?

In the directory root of the site, there are 2 folders catalog and sale. The catalog contains a complex bitrix component - catalog.
index.php from sale connects via require_once index.php from catalog folder.
Discounts for certain products are configured in the bitrix admin panel.
If the call goes to the sale folder, then the arrFilter array is created and passed to the FILTER_NAME of the catalog component.
The question is what exactly needs to be passed to $arrFilter so that only products with a valid discount are displayed on /sale/?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Nikolaev, 2019-06-28
@nikolaevevge

Now I decided as follows, and if you have a different solution - please suggest !
require($_SERVER['DOCUMENT_ROOT'].'/local/templates/main/phpscripts/myGetBasketData.php');// the class is needed to get the Id of discounted products
$myGetBasketData = new myGetBasketData;
global $arrFilter;
$arrFilter = array();
$arrFilter["=ID"] = $myGetBasketData->getProductIdDiscontAr();
then we pass $arrFilter to the bitrix catalog complex component via FILTER_NAME, namely
$APPLICATION->IncludeComponent(
"bitrix:catalog",
"new_catalog",
array(
"FILTER_NAME" => "arrFilter",
...
the myGetBasketData class is available in the listing of the myGetBasketData.php class file at blog.ivru.net/?id=96
Important! The method returns an array of products with a discount, only when the discount is created directly for the product, that is, as shown in the screenshot.
The algorithm of the method for determining the Id of goods with a discount of the getProductIdDiscontAr() method is approximately the following:
1) a list of discounts is obtained through CSaleDiscount::GetList
2) then in foreach Ids of discounts are passed to CSaleDiscount::GetByID
3) the returned data is checked for the presence and not the absence of the array key [ "CONDITIONS"]
4) if the string exists and is not empty, data is parsed from Equal";s:5:"value";a: to }
5) if such data is found, then they are parsed multiple times from i: to ;
6) every second value is the Id of the product for which the discount applies (these Ids are collected in the $prodIdAr array and returned by the getProductIdDiscontAr method)
Thus, if your discounts are not explicitly indicated for the product, but for example by properties, then the method must be added for such discounts .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question