S
S
serik2020-08-22 22:28:42
1C-Bitrix
serik, 2020-08-22 22:28:42

How to make your own property in the trade offer of the product card?

I'm picking a standard solution - an online store, small business editors, stuck in product cards.
I want to make such an analogue of the filter by trade offer
5f4170e354545952565809.png

. The first selection is standard, I added "Offer - OFFERS"
5f4170f9aeb47753864070.png
in the call to the "bitrix:catalog" component, stuffed this property everywhere where typical properties are called

on the screen below, the place where these "filters" are called is the
second screen - bitrix component call parameters:catalog.element
3 screen - main component call parameters - catalog
5f417140b572d123975302.png
5f4171492b324550378737.png
5f41714ea8020140315185.png
And this is killing me, I don’t understand what to do with it, and how to add my own filters
"DETAIL_PRODUCT_INFO_BLOCK_ORDER" => "sku,props",

(* and please, don't write about the fact that I'm posting the code with screenshots, here you need to focus on visual contact so that it's clear what I'm talking about)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2020-08-23
@black_xe

in the result_modifier.php file of your catalog.element component template after the method

$arParams = $component->applyTemplateModifications();

add
if($arResult['OFFERS']) {
  $colorPropertyCode = 'COLOR_REF';
  
  foreach($arResult['OFFERS'] as $key => $offer) {
    $colors = $arResult['SKU_PROPS'][$colorPropertyCode]['VALUES'];
    $offerColorXmlId = $offer['PROPERTIES'][$colorPropertyCode]['VALUE'];
    $offerColorImage = [];
    
    foreach($colors as $color) {
      if($color['XML_ID'] == $offerColorXmlId) {
        if(is_array($color['PICT']) && $color['PICT']['SRC']) {
          $offerColorImage = $color['PICT'];
        }
        break;
      }
    }

    if($offerColorImage) {
      ++$arResult['OFFERS'][$key]['MORE_PHOTO_COUNT'];
      array_unshift($arResult['OFFERS'][$key]['MORE_PHOTO'], $offerColorImage);
      
      ++$arResult['JS_OFFERS'][$key]['SLIDER_COUNT'];
      array_unshift($arResult['JS_OFFERS'][$key]['SLIDER'], $offerColorImage);
    }
  }
}

Just change this line $colorPropertyCode = 'COLOR_REF'; COLOR_REF - character code of the trade offers infoblock color property

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question