<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Форум ReadyScript &mdash; Расширение текста для индексации в каталоге]]></title>
	<link rel="self" href="https://forum.readyscript.ru/feed/atom/topic/1339/" />
	<updated>2017-08-31T14:02:45Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.readyscript.ru/topic/1339/rasshirenie-teksta-dlya-indeksatsii-v-kataloge/</id>
		<entry>
			<title type="html"><![CDATA[Re: Расширение текста для индексации в каталоге]]></title>
			<link rel="alternate" href="https://forum.readyscript.ru/post/7674/#p7674" />
			<content type="html"><![CDATA[<p>Подцепился, все прекрасно, благодарю!</p>]]></content>
			<author>
				<name><![CDATA[Алексей]]></name>
				<uri>https://forum.readyscript.ru/user/747/</uri>
			</author>
			<updated>2017-08-31T14:02:45Z</updated>
			<id>https://forum.readyscript.ru/post/7674/#p7674</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Расширение текста для индексации в каталоге]]></title>
			<link rel="alternate" href="https://forum.readyscript.ru/post/7673/#p7673" />
			<content type="html"><![CDATA[<p>Вот так будет:</p><div class="codebox"><pre><code>        $event_result = \RS\Event\Manager::fire(&#039;product.getsearchtext&#039;, array(
            &#039;text_parts&#039; =&gt; $text,
            &#039;product&#039; =&gt; $this
        ));
        list($text) = $event_result-&gt;extract();</code></pre></div>]]></content>
			<author>
				<name><![CDATA[admin]]></name>
				<uri>https://forum.readyscript.ru/user/2/</uri>
			</author>
			<updated>2017-08-31T08:53:12Z</updated>
			<id>https://forum.readyscript.ru/post/7673/#p7673</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Расширение текста для индексации в каталоге]]></title>
			<link rel="alternate" href="https://forum.readyscript.ru/post/7672/#p7672" />
			<content type="html"><![CDATA[<p>Созрел еще вопрос, хук я прописал, текст получил, а как бы мне получить еще при этом модель товара или хотя бы ID, чтоб вытащить поле, которое у каждого товара уникально?</p>]]></content>
			<author>
				<name><![CDATA[Алексей]]></name>
				<uri>https://forum.readyscript.ru/user/747/</uri>
			</author>
			<updated>2017-08-30T10:44:25Z</updated>
			<id>https://forum.readyscript.ru/post/7672/#p7672</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Расширение текста для индексации в каталоге]]></title>
			<link rel="alternate" href="https://forum.readyscript.ru/post/7671/#p7671" />
			<content type="html"><![CDATA[<p>Спасибо большое за оперативность!</p>]]></content>
			<author>
				<name><![CDATA[Алексей]]></name>
				<uri>https://forum.readyscript.ru/user/747/</uri>
			</author>
			<updated>2017-08-30T03:25:06Z</updated>
			<id>https://forum.readyscript.ru/post/7671/#p7671</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Расширение текста для индексации в каталоге]]></title>
			<link rel="alternate" href="https://forum.readyscript.ru/post/7670/#p7670" />
			<content type="html"><![CDATA[<p>Добрый день! <br />Добавили хук product.getsearchtext, войдет в следующее обновление.<br />Чтобы не ждать можете добавить 4 строки сами в файл product.inc.php</p><div class="codebox"><pre><code>    /**
    * Возвращает текст для индексации. Должен содержать все слова, по которым товар должен находиться
    */
    function getSearchText()
    {
        $config = \RS\Config\Loader::byModule($this);
        //Для поиска: Штрих-код, Краткое опиание, Характеристики, мета ключевые слова
        $properties = &#039;&#039;;
        if (in_array(&#039;properties&#039;, $config[&#039;search_fields&#039;])) {
            if ($this-&gt;use_property_in_search_index) {
                foreach ($this-&gt;fillProperty() as $groups) {
                    foreach ($groups[&#039;properties&#039;] as $prop) {
                        $properties .= $prop[&#039;title&#039;] . &#039; : &#039; . $prop-&gt;textView() . &#039; , &#039;;
                    }
                }
            }
        }

        $text = array();
        
        if (in_array(&#039;barcode&#039;, $config[&#039;search_fields&#039;])) $text[] = $this[&#039;barcode&#039;];
        if (in_array(&#039;short_description&#039;, $config[&#039;search_fields&#039;])) $text[] = $this[&#039;short_description&#039;];
        if (in_array(&#039;properties&#039;, $config[&#039;search_fields&#039;])) $text[] = $properties;
        if (in_array(&#039;meta_keywords&#039;, $config[&#039;search_fields&#039;])) $text[] = $this[&#039;meta_keywords&#039;];

        //Начало хука
        $event_result = \RS\Event\Manager::fire(&#039;product.getsearchtext&#039;, array(
            &#039;text_parts&#039; =&gt; $text
        ));
        list($text) = $event_result-&gt;extract();
        //Конец хука

        return trim(strip_tags(implode(&#039; , &#039;, $text)));
    }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[admin]]></name>
				<uri>https://forum.readyscript.ru/user/2/</uri>
			</author>
			<updated>2017-08-29T21:28:00Z</updated>
			<id>https://forum.readyscript.ru/post/7670/#p7670</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Расширение текста для индексации в каталоге]]></title>
			<link rel="alternate" href="https://forum.readyscript.ru/post/7669/#p7669" />
			<content type="html"><![CDATA[<p>Я пишу сторонний модуль, он добавляет свое поле в карточку товара, примерно как артикул, но отдельный (тк основной артикул занят или заполняется вручную). Нужно организовать поиск по этому полю на сайте.</p><p>После просмотра исходного кода, обнаружил, что хуков для добавления этого поля в текст для индексации нет. Не хотелось бы менять исходный код модуля, но как-то вклинится я туда не против.</p><p><span class="postimg"><img src="http://dl4.joxi.net/drive/2017/08/29/0002/3050/162794/94/2f7db3a662.jpg" alt="http://dl4.joxi.net/drive/2017/08/29/0002/3050/162794/94/2f7db3a662.jpg" /></span></p><p><strong>Есть ли возможность доработать этот вопрос?</strong> Именно возможность расширять функцию \Catalog\Model\Orm\getSearchText().</p>]]></content>
			<author>
				<name><![CDATA[Алексей]]></name>
				<uri>https://forum.readyscript.ru/user/747/</uri>
			</author>
			<updated>2017-08-29T15:16:35Z</updated>
			<id>https://forum.readyscript.ru/post/7669/#p7669</id>
		</entry>
</feed>
