YML файл для маркета при использовании minishop2

Создаем документ и скрываем из меню.
У документа:
— указываем Тип содержимого — «XML»;
— замораживаем адрес, какой нам необходим.
— шаблон выбираем «Пустой»
— в содержимое добавляем:

{set $categories = '13,18,71,14,15,72,21,73,16,20,17'}
<?xml version="1.0" encoding="windows-1251"?>
<yml_catalog date="{'' | date : 'Y-m-d H:i'}" >
<shop>
<name>{$_modx->config.site_name}</name>
<company>{$_modx->config.site_name}</company>
<url>{$_modx->config.site_url}</url>
<currencies>
<currency id="RUR" rate="1"/>
</currencies>
<categories>
    {$_modx->runSnippet('pdoResources', [
        'parents'=>'0',
        'tpl'=>'tpl.yamarket.category.item',
    	'resources'=>$categories,
    	'depth'=>'10',
    	'sortby' => 'menuindex',
    	'sortdir' => 'ASC',
    	'where' => ['class_key' => 'msCategory'],
    	'showHidden' => '1',
    	'limit'=>'0',
    ])}
</categories>
<offers>
    {$_modx->runSnippet('msProducts', [
        'templates'=>'11',
        'parents'=>$categories
        'includeTVs'=>'big',
        'tvPrefix'=>'0',
        'tpl'=>'tpl.yamarket.offer.item',
        'limit'=>'0',
    ])}
</offers>
</shop>
</yml_catalog>
Категории нужно было выводить определенные, поэтому в самом начале идет их определение.
Еще потребуются чанки
tpl.yamarket.category.item
<category id="{$id}" {if $id!=13}parentId="{$parent}"{/if}>{$pagetitle}</category>
Где 13 — id родительской категории товаров.

tpl.yamarket.offer.item
<offer id="{$id}" available="true">
    <url>{$id | url : ['scheme' => 'full']}</url>
    <price>{$price | replace : " " : ""}</price>
    <currencyId>RUR</currencyId>
    <categoryId>{$parent}</categoryId>
    <picture>{($_modx->config.site_url ~ $image) | replace : "//" : "/"}</picture>
    <name>{$pagetitle}</name>
    <description>{$description}</description>
</offer>

Немножко скринов



Нет комментариев