E
E
entermix2016-04-21 15:03:46
1C-Bitrix
entermix, 2016-04-21 15:03:46

How to display only certain elements in bitrix:catalog?

Which parameter specifies the items to be displayed in the catalog?
Tried like this but doesn't work

$arrFilter = Array( 
"SECTION_ID" => 1,
);

$APPLICATION->IncludeComponent(
  "bitrix:catalog",
  ".default",
  Array(
    "IBLOCK_TYPE" => "catalog",
    "IBLOCK_ID" => "3",
    "BASKET_URL" => "/personal/basket.php",
    "ACTION_VARIABLE" => "action",
    "PRODUCT_ID_VARIABLE" => "id",
    "SECTION_ID_VARIABLE" => "SECTION_ID",
    "SEF_MODE" => "Y",
    "SEF_FOLDER" => "/catalog/",
    "AJAX_MODE" => "N",
    "AJAX_OPTION_SHADOW" => "N",
    "AJAX_OPTION_JUMP" => "N",
    "AJAX_OPTION_STYLE" => "Y",
    "AJAX_OPTION_HISTORY" => "N",
    "CACHE_TYPE" => "N",
    "CACHE_TIME" => "0",
    "CACHE_FILTER" => "Y",
    "CACHE_GROUPS" => "Y",
    "SET_TITLE" => "N",
    "SET_STATUS_404" => "N",
    "USE_FILTER" => "N",
        "FILTER_NAME" => "arrFilter",

    "USE_REVIEW" => "N",
    "USE_COMPARE" => "N",
    "PRICE_CODE" => array(0=>"BASE",),
    "USE_PRICE_COUNT" => "Y",
    "SHOW_PRICE_COUNT" => "",
    "PRICE_VAT_INCLUDE" => "Y",
    "PRICE_VAT_SHOW_VALUE" => "Y",
    "SHOW_TOP_ELEMENTS" => "N",
    "PAGE_ELEMENT_COUNT" => "21",
    "LINE_ELEMENT_COUNT" => "3",
    "ELEMENT_SORT_FIELD" => "sort",
    "ELEMENT_SORT_ORDER" => "asc",
    "LIST_PROPERTY_CODE" => array(0=>"TYPE",1=>"SIZE",2=>"MANUFACTURER",3=>"COLOR",4=>"SPECIALOFFER",5=>"NEWPRODUCT",6=>"SALELEADER",7=>"",8=>"ARTNUMBER",9=>"MATERIAL",10=>"OLD_PRICE",11=>"",),
    "INCLUDE_SUBSECTIONS" => "Y",
    "LIST_META_KEYWORDS" => "UF_KEYW",
    "LIST_META_DESCRIPTION" => "UF_DESC",
    "LIST_BROWSER_TITLE" => "UF_TITLE",
    "DETAIL_PROPERTY_CODE" => array(0=>"TYPE",1=>"SIZE",2=>"COLLECTION",3=>"MANUFACTURER",4=>"COUNTRY",5=>"COLOR",6=>"SPECIALOFFER",7=>"NEWPRODUCT",8=>"SALELEADER",9=>"",10=>"ARTNUMBER",11=>"MATERIAL",12=>"OLD_PRICE",13=>"",),
    "DETAIL_META_KEYWORDS" => "",
    "DETAIL_META_DESCRIPTION" => "",
    "DETAIL_BROWSER_TITLE" => "-",
    "LINK_IBLOCK_TYPE" => "catalog",
    "LINK_IBLOCK_ID" => "6",
    "LINK_PROPERTY_SID" => "ID_VAR",
    "LINK_ELEMENTS_URL" => "link.php?PARENT_ELEMENT_ID=#ELEMENT_ID#",
    "USE_ALSO_BUY" => "N",
    "DISPLAY_TOP_PAGER" => "N",
    "DISPLAY_BOTTOM_PAGER" => "Y",
    "PAGER_TITLE" => "Товары",
    "PAGER_SHOW_ALWAYS" => "N",
    "PAGER_TEMPLATE" => "vsestupeni",
    "PAGER_DESC_NUMBERING" => "N",
    "PAGER_DESC_NUMBERING_CACHE_TIME" => "36000",
    "PAGER_SHOW_ALL" => "Y",
    "AJAX_OPTION_ADDITIONAL" => "",
    "SEF_URL_TEMPLATES" => Array(
      "sections" => "",
      "section" => "#SECTION_CODE#/",
      "element" => "#SECTION_CODE#/#ELEMENT_CODE#/",
      "compare" => "compare.php?action=#ACTION_CODE#"
    ),
    "VARIABLE_ALIASES" => Array(
      "sections" => Array(),
      "section" => Array(),
      "element" => Array(),
      "compare" => Array(
        "ACTION_CODE" => "action"
      ),
    )
  )
);

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
no_one_safe, 2016-04-21
@entermix

"FILTER_NAME" => "arrFilter",
UPD. Did NOT notice this parameter specified.
The problem is that the catalog.section component does not accept the global filter [And does not work with it in the code]. Yes, such a problem.
Option 2:
1. Use catalog.top for output (Which this filter takes into account)
2. Finish catalog.section. Move to your space and on line 466

$arFilter = array(
    "IBLOCK_ID"=>$arParams["IBLOCK_ID"],
    "IBLOCK_ACTIVE"=>"Y",
    "ACTIVE"=>"Y",
    "GLOBAL_ACTIVE"=>"Y",
  );

replace with about
if(strlen($arParams["FILTER_NAME"])<=0 || !preg_match("/^[A-Za-z_][A-Za-z01-9_]*$/", $arParams["FILTER_NAME"]))
{
  $arrFilter = array();
}
else
{
  $arrFilter = $GLOBALS[$arParams["FILTER_NAME"]];
  if(!is_array($arrFilter))
    $arrFilter = array();
}
$arFilter = array_merge(array(
    "IBLOCK_ID"=>$arParams["IBLOCK_ID"],
    "IBLOCK_ACTIVE"=>"Y",
    "ACTIVE"=>"Y",
    "GLOBAL_ACTIVE"=>"Y",
  ),$arrFilter);

Of course, at the same time, add the filter name to $arParams in the section.php file in the component template, i.e.
"FILTER_NAME" => $arParams['FILTER_NAME'],

K
kompi, 2016-04-21
@kompi

You can filter by different parameters: sections, tags, etc.
By default, if I'm not mistaken, all active elements of the infoblock are displayed.

A
Alexey Zakharov, 2016-04-21
@konratnox

See the global filter, here is an example dev.1c-bitrix.ru/support/forum/forum6/topic56973

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question