Home computickets Bitrix Search Component

Bitrix Search Component

Author

Date

Category

How to set up a search What would he search only for goods?
Now he gives goods and sections, and the other is an element of an array of the result, which in the investigation stretches the pagination as well as a certain number of elements, among which and partitions are displayed. Ie just hide them will not work, you need to search for goods only.

& lt; $ application- & gt; includecomponent (
  "Bitrix: search.page",
  "search.main",
  Array (
  "Restart" = & gt; "N", // Search without a morphology (in the absence of search result)
    "Check_dates" = & gt; "N", // look only in active documents by the date of documents
    "Use_title_rank" = & gt; "N", // When ranking the result, take into account headlines
    "Default_Sort" = & gt; "RANK", // Sort by default
    "ArrFilter" = & gt; Array (// Restriction of the search area
      0 = & gt; "iblock_catalog",
    ),
// "arrfilter_main" = & gt; "",
// "arrfilter_iblock_services" = & gt; Array (
// 0 = & gt; "All",
//),
// "arrfilter_iblock_news" = & gt; Array (
// 0 = & gt; "All",
//),
    "arrfilter_iblock_catalog" = & gt; Array (// Search in information blocks like "iblock_catalog"
      0 = & gt; "All",
    ),
    "Show_where" = & gt; "N", // Show the drop-down list "Where to look"
    "Show_when" = & gt; "N", // Show filter by dates
    "Page_Result_Count" = & gt; "24", // Number of results on the page
    "Ajax_mode" = & gt; "N", // Enable AJAX Mode
    "Ajax_option_shadow" = & gt; "Y",
    "Ajax_option_jump" = & gt; "N", // Enable scrolling to the beginning of the component
    "Ajax_option_style" = & gt; "Y", // Enable styles loading
    "AJAX_OPTION_HISTORY" = & gt; "N", // Enable browser navigation emulation
    "Cache_type" = & gt; "A", // type of caching
    "Cache_time" = & gt; "36000000", // caching time (sec.)
    "Display_top_pager" = & gt; "N", // withdraw over the results
    "Display_bottom_pager" = & gt; "Y", // Display under the results
    "Pager_title" = & gt; "Search Results", // Title Search Results
    "Pager_Show_always" = & gt; "N", // withdraw always
    "Pager_Template" = & gt; "Lenal", // Title Template
    "Use_suggest" = & gt; "N", // Show a prompt with search engines
    "Show_item_tags" = & gt; "N", // Show Document Tags
    "Show_item_date_change" = & gt; "N", // Show the Date Change Date
    "Show_Order_by" = & gt; "N", // Show sorting
    "Show_tags_cloud" = & gt; "N", // Show Tag Cloud
    "AJAX_OPTION_ADDITIONAL" = & gt; "", // Additional identifier
    "NO_WORD_LOGIC" = & gt; "N", // Disable word processing as logical operators
    "Filter_name" = & gt; "", // Additional filter
    "arrfilter_iblock_visible_goods" = & gt; Array (
      0 = & gt; "All",
    ),
    "Use_language_guess" = & gt; "Y", // Enable Auto Detection of the keyboard layout
    "Show_Rating" = & gt; "",
    "Rating_Type" = & gt; "LIKE_GRAPHIC",
    "Path_to_user_profile" = & gt; "",
    "COMPONENT_TEMPLATE" = & gt; "Clear"
  ),
  false
);? & gt;

Answer 1, Authority 100%

In my opinion the easiest option:

1) Add handler beforeindex Additional parameters for goods. That is, we check that the indexed element is a product and add your parameter, for example:

$ arfields ["params"] ["is_product"] = 'y';

2) Add a filter to this parameter for the search component. It turns out something like this:

global $ arsearchfilter;
$ ARSEARCHFILTER = [
  'Params' = & gt; [
    'is_product' = & gt; 'Y'
  ]
];
$ Application- & gt; includecomponent (
   "Bitrix: search.page",
   "Searchpage",
   Array ( 
"Filter_name" = & gt; "ARSEARCHFILTER",
    //// the remaining parameters
   ),
   false
);

Answer 2

Here either processing the component, or in the Bitrix template: search.page you need to filter the results already obtained.

Something like this

$ filtelements = [];
$ getelements = ciblockelement :: getlist (
    [],
    [
      'Iblock_id' = & gt; 52,
      '= Id' = & gt; $ alelements
    ],
    false
    false
    [
      'ID'
    ]
);
While ($ elm = $ GetElements- & gt; fetch ())
{
  $ Filtelements [] = $ ELM;
}

and the filter is already added to the component for the output of the elements.

Kostl is also, Kaneshne. Well, what to do with this bitrix.

or the second option to make your component based on the current and correct the sample in it. So it will be more correct

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions