C
C
Coraelstraze2017-01-18 13:17:23
PHP
Coraelstraze, 2017-01-18 13:17:23

Selection of goods by Bitrix property?

Hello! For an online store, in the product card, you need to organize a block in which products with the label "new" and "sale" will be displayed.
I did it through the catalog.section component. All goods are displayed. Display of all properties of goods in the settings set. I write the first two lines: I create a new array for the filter by the "NEWPRODUCT" property.
As he no longer shamanized and wrote this way and that - emptiness. Doesn't display items tagged new.
What can be a jamb?
Thank you.
<?
global $arrFilternovelty;
$arrFilternovelty = Array('PROPERTY_NEWPRODUCT_VALUE' => 'Y');
$APPLICATION->IncludeComponent("bitrix:catalog.section", "for_product", Array(
"ACTION_VARIABLE" =>
"ADD_PICT_PROP" => "MORE_PHOTO", // An additional picture of the main product
"ADD_PROPERTIES_TO_BASKET" => "Y", // Add properties of products and offers to the cart
"ADD_SECTIONS_CHAIN" => "N", // Include the section in the navigation chain
" ADD_TO_BASKET_ACTION" => "ADD", // Show add to cart or buy
button "AJAX_MODE" => "N", // Enable AJAX mode
"AJAX_OPTION_ADDITIONAL" => "", // Additional identifier
"AJAX_OPTION_HISTORY" => "N ", // Enable browser navigation emulation
"AJAX_OPTION_JUMP" => "N",// Enable scrolling to the beginning of the component
"AJAX_OPTION_STYLE" => "Y", // Enable style loading
"BACKGROUND_IMAGE" => "-", // Set the background image for the template from the property
"BASKET_URL" => "/personal/basket.php", // URL leading to the shopping cart page
"BROWSER_TITLE" => "-", // Set the title of the browser window from the property
"CACHE_FILTER" => "N", // Cache with the filter set
"CACHE_GROUPS" => "Y", // Consider access rights
"CACHE_TIME" => "36000000", // Caching time (sec.)
"CACHE_TYPE" => "A", // Caching type
"CONVERT_CURRENCY" => "N", // Show prices in one currency
"DETAIL_URL" => "", // URL leading to the page with the content of the section element
"DISABLE_INIT_JS_IN_COMPONENT" =>"N", // Do not include js libraries in the
"DISPLAY_BOTTOM_PAGER" => "Y", // Display under the list
"DISPLAY_TOP_PAGER" => "N", // Display above the list
"ELEMENT_SORT_FIELD" => "sort", // By which field we sort the elements
"ELEMENT_SORT_FIELD2" => "id", // Field for the second sorting of elements
"ELEMENT_SORT_ORDER" = > "asc", // Sorting order of elements
"ELEMENT_SORT_ORDER2" => "desc", // Order of the second sorting of elements
"FILTER_NAME" => "arrFilternovelty", // Name of the array with filter values ​​for filtering elements
"HIDE_NOT_AVAILABLE" => " N", // Goods not in stock
"IBLOCK_ID" => "2", // Info block
"IBLOCK_TYPE" => "catalog", // Infoblock type
"INCLUDE_SUBSECTIONS" => "Y", // Show elements of section subsections
"LABEL_PROP" => "NEWPRODUCT", // Product label property
"LINE_ELEMENT_COUNT" => "3", // Number of elements displayed in one line of the table
"MESSAGE_404" => "", // Message to display (by default from the component)
"MESS_BTN_ADD_TO_BASKET" => "Add to cart", // Text "Add to Cart"
buttons "MESS_BTN_BUY" => "Buy", // Text of the "Buy" button
"MESS_BTN_DETAIL" => "Details", // Text of the "Details" button
"MESS_BTN_SUBSCRIBE" => "Subscribe", // Text "Notify about arrival"
buttons "MESS_NOT_AVAILABLE" => "Out of stock", // Message about the absence of goods
"META_DESCRIPTION" => "-",// Set page description from property
"META_KEYWORDS" => "-", // Set page keywords from property
"OFFERS_CART_PROPERTIES" => array( // Offer properties added to cart
0 => "ARTNUMBER",
1 => "COLOR_REF",
2 => "SIZES_SHOES",
3 => "SIZES_CLOTHES",
),
"OFFERS_FIELD_CODE" => array( // Offer fields
0 => "ID",
1 => "CODE",
2 => "XML_ID",
3 => "NAME",
4 => "TAGS",
5 => "SORT",
6 = > "PREVIEW_TEXT",
7 => "PREVIEW_PICTURE",
8 => "DETAIL_TEXT",
9 => "DETAIL_PICTURE",
10 => "DATE_ACTIVE_FROM",
11 => "ACTIVE_FROM",
12 => "DATE_ACTIVE_TO",
13 => "ACTIVE_TO",
14 => "SHOW_COUNTER",
15 => "SHOW_COUNTER_START",
16 => "IBLOCK_TYPE_ID",
17 => "IBLOCK_ID",
18 => "IBLOCK_CODE",
19 => "IBLOCK_NAME",
20 => "IBLOCK_EXTERNAL_ID",
21 => "DATE_CREATE",
22 => "CREATED_BY",
23 => "CREATED_USER_NAME",
24 => "TIMESTAMP_X",
25 => "MODIFIED_BY",
26 => "USER_NAME",
27 => "",
),
"OFFERS_LIMIT" => "5" , // Maximum number of offers to display (0 - all)
"OFFERS_PROPERTY_CODE" =>array( // Offer properties
0 => "ARTNUMBER",
1 => "COLOR_REF",
2 => "SIZES_SHOES",
3 => "SIZES_CLOTHES",
4 => "MORE_PHOTO",
5 => "",
),
"OFFERS_SORT_FIELD" => "sort", // By which field we sort product offers
"OFFERS_SORT_FIELD2" => "id", // Field for the second sorting of product offers
"OFFERS_SORT_ORDER" => "asc" , // Sorting order of product offers
"OFFERS_SORT_ORDER2" => "desc", // Second sorting order of product offers
"PAGER_BASE_LINK_ENABLE" => "N", // Enable link processing
"PAGER_DESC_NUMBERING" => "N", // Use reverse navigation
"PAGER_DESC_NUMBERING_CACHE_TIME" => "36000", // Page cache time for reverse navigation
"PAGER_SHOW_ALL" => "N", // Show "All" link "PAGER_SHOW_ALWAYS" => "N", // Display
always
"PAGER_TEMPLATE" => ".default", // Page navigation template
"PAGER_TITLE" => "Products", // Category name
"PAGE_ELEMENT_COUNT" => "30", // Number of items on the page
"PARTIAL_PRODUCT_PROPERTIES" => "Y ", // Allow adding products to the cart that do not have all the characteristics
"PRICE_CODE" => array( // Price type
0 => "BASE",
),
"PRICE_VAT_INCLUDE" => "Y", // Include VAT in price
"PRODUCT_DISPLAY_MODE" => "Y", // Display scheme
"PRODUCT_ID_VARIABLE" => "id", // Variable name,in which the product code for the purchase is passed
"PRODUCT_PROPERTIES" => array( // Product characteristics
0 => "BRAND_REF",
1 => "NEWPRODUCT",
2 => "SALELEADER",
3 => "SPECIALOFFER",
4 => "MATERIAL",
5 => "F_USER",
6 => "RECOMMEND",
),
"PRODUCT_PROPS_VARIABLE" => "prop", // Variable name , in which product characteristics are passed
"PRODUCT_QUANTITY_VARIABLE" => "", // Variable name, in which the quantity of goods is passed
"PRODUCT_SUBSCRIPTION" => "N", // Enable alerts for out of stock products
"PROPERTY_CODE" => array( // Properties
0 => "TITLE",
1 => "KEYWORDS",
2 => "META_DESCRIPTION",
3 =>"BRAND_REF",
4 => "NEWPRODUCT",
5 => "SALELEADER",
6 => "SPECIALOFFER",
7 => "ARTNUMBER",
8 => "MANUFACTURER",
9 => "MATERIAL",
10 => "COLOR",
11 => "BLOG_POST_ID",
12 => "F_USER",
13 => "BLOG_COMMENTS_CNT",
14 => "FORUM_MESSAGE_CNT",
15 => "vote_count",
16 => "rating",
17 => "RECOMMEND",
18 => "vote_sum",
19 => "FORUM_TOPIC_ID",
20 => "MINIMUM_PRICE",
21 => "MAXIMUM_PRICE",
22 = > "",
),
"SECTION_CODE" => "", // Section code
"SECTION_ID" => $_REQUEST["SECTION_ID"], // Section ID
"SECTION_ID_VARIABLE" => "SECTION_ID", // Name of the variable in which the group code is passed
"SECTION_URL" => "", // URL leading to the page with section content
"SECTION_USER_FIELDS" => array( // Section properties
0 => "UF_BROWSER_TITLE",
1 => "UF_KEYWORDS",
2 => "UF_META_DESCRIPTION",
3 => "UF_BACKGROUND_IMAGE",
4 => "",
),
"SEF_MODE" => "N", // Enable CNC support
"SET_BROWSER_TITLE" => "Y", // Set browser window title
"SET_LAST_MODIFIED" => " N", // Set the page modification time in response headers
"SET_META_DESCRIPTION" => "Y",// Set page description
"SET_META_KEYWORDS" => "Y", // Set page keywords
"SET_STATUS_404" => "N", // Set status 404
"SET_TITLE" => "Y", // Set the title of the page
"SHOW_404" => "N", // Show a special page
"SHOW_ALL_WO_SECTION" => "Y", // Show all elements if no section is specified
"SHOW_CLOSE_POPUP" => "N", // Show continue shopping button in popups
"SHOW_DISCOUNT_PERCENT" => "N", // Show discount percentage
"SHOW_OLD_PRICE" => "N", // Show old price
"SHOW_PRICE_COUNT" => "1 ", // Display prices for quantities
"TEMPLATE_THEME" => "blue", // Color theme
"USE_MAIN_ELEMENT_SECTION" => "N",// Use the main section to show the element
"USE_PRICE_COUNT" => "N", // Use the display of prices with ranges
"USE_PRODUCT_QUANTITY" => "N", // Allow specifying the quantity of goods
"COMPONENT_TEMPLATE" => ".default",
"SEF_RULE" => "", // Rule for processing
"SECTION_CODE_PATH" => "",
"OFFER_ADD_PICT_PROP" = > "MORE_PHOTO", // Additional pictures of the offer
"OFFER_TREE_PROPS" => "", // Properties for selection of offers
),
false
);?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Korolev, 2017-01-18
@Coraelstraze

What if you do that?
$arrFilternovelty = Array('!PROPERTY_NEWPRODUCT' => false);
NEWPRODUCT is of type "List"?
If you write PROPERTY_NEWPRODUCT_VALUE in the filter, then you need to compare it with the value of the list property, for example:
$arrFilternovelty = Array('PROPERTY_NEWPRODUCT_VALUE' => 'Yes');
or so, if the property value "Yes" has XML_ID 'Y':
$arrFilternovelty = Array('PROPERTY_NEWPRODUCT_VALUE_XML_ID' => 'Y');

A
Andrey Nikolaev, 2017-01-18
@gromdron

What type of property does your NEWPRODUCT have?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question