I want to override the query() method of the Facet() class of a smart filter. In init.php I write:

 class FacetMod extends \Bitrix\Iblock\PropertyIndex\Facet { public function query(array $filter, array $facetTypes = array(), $facetId = 0) { /*код */ } } 

As a result, the error:

 Class '\Bitrix\Iblock\PropertyIndex\Facet' not found in C:\Bitrix\www\bitrix\php_interface\init.php 

Why does not find this class can not understand.

    3 answers 3

    The information block module itself was not connected: \Bitrix\Main\Loader::includeModule("iblock")

      Maybe try so

       use \Bitrix\Iblock\PropertyIndex\Facet class FacetMod extends \Bitrix\Iblock\PropertyIndex\Facet { // you rewrite } 
      • does not help, already connected use Bitrix\Iblock\PropertyIndex\Facet; use Bitrix\Main\Loader; use Bitrix\Catalog; use Bitrix\Iblock\PropertyIndex\Facet; use Bitrix\Main\Loader; use Bitrix\Catalog; - Nikolay
      • class FacetMod extends Facet { and try this class FacetMod extends Facet { . And look in the file Facet.php what the class is called there may be the problem. - Naumov

      I advise you not to make edits in the file \Bitrix\www\bitrix\php_interface\init.php .

      Create a copy of the file in \Bitrix\www\local\php_interface\init.php

      Plus, if you want to edit the class itself, I advise you also to do everything through the /local folder.

      For example: www\bitrix\modules\iblock\lib\propertyindex\ -> www\local\modules\iblock\lib\propertyindex\ and copy here facet.php and already inside it we run function query()

      • Argue, please. - Nikolai
      • Because of the bitrix updates, the bitrix when updating updates all files in the / bitrix folder, if there are any in the new version - Sorrymelame
      • not all files, in particular, the php_interface folder is not affected - Nikolay