It is necessary to modify the functionality of the “smart filter” in Bitrix, so that you can select the option of the presence / absence of goods in stock.

Tell me how you can add to the “smart filter” parameter “sorting by the presence of goods in stock”? Do I need to create a new property for merchandise and SKU? In the component of the catalog there is a parameter HIDE_NOT_AVAILABLE (screenshot - http://prntscr.com/bvwoxo ), can this parameter be added to the “smart filter” and how to do it?

  • Creating a property is not necessary. In your case, you need to add the checkbox to the filter form, tracking the value of which you will set / remove the value of the HIDE_NOT_AVAILABLE parameter. I would recommend to do this with a button by clicking on which to change the parameter value, with the button it is somewhat easier than with a tick in the form of a filter, you can take a form outside the limits of the filter's shape - make a switch for yourself. - Nikolaj Sarry
  • just add the checkbox to the form layout? In the checkbox register name as HIDE_NOT_AVAILABLE? I understand you correctly - inviziblll
  • If you are given an exhaustive answer, mark it as correct (tick the selected answer). - Mihanik71
  • 3
    Possible duplicate question: [How can I add the “filtering by the presence of goods in stock” parameter in the “smart filter” without creating an additional property in the information block?] ( Ru.stackoverflow.com/questions/547487/… - Nikolaj Sarry
  • @NikolaiSarrah in fact, the questions are similar, but the solutions are different - Mihanik71

1 answer 1

HIDE_NOT_AVAILABLE is the setting of the component to show or products that are not available for order. After enabling this option, you may encounter the following problems:

  • In the store settings there is a tick "allow to buy products with a negative amount"
  • The same tick is in the product
  • There is a main product, but out of stock there are no trade offers; the products will be shown in the list.
  • There is no quantity of the main product, but there are commercial offers - the goods will not be listed.

I think the best option in this situation is to add the “goods in stock” property. Output in the filter. Check the value in the complex component after the filter. Code:

 /* компонент catalog.smart.filter */ <? global $arrFilter; if($arrFilter["PROPERTY_X"] == "Y") $arrFilter[">CATALOG_QUANTITY"] = 0; ?> /* компонент catalog.section */ 

And when changing goods, fill this property, and if there is integration with 1C, then do another check on the krone.

This option will allow the filter to work "as it should." CNC, ajax caching, etc. will work. Plus, it gives us additional opportunities to manage the quantity - there are situations when the product is considered unavailable, it is less than 10, for example, or we can configure this parameter for partitions separately.

  • "Check the value in the complex component after the filter." - the code that you showed it must be added to the component and not to the template? or all the same to the template - inviziblll
  • one
    Do not violate the first rule of development on bitrix and add to the template. The bitrix complex component template: catalog. Do you understand everything by code? - Mihanik71
  • put in the file bitrix: catalog / [tamplate_name] /section.php between the bitrix: catalog.smart.filter and bitrix: catalog.section? - inviziblll
  • thanks for the help - inviziblll 2:26 pm
  • one
    @inviziblll If you are given an exhaustive answer, mark it as correct (tick the selected answer). - Mihanik71