Skip to content

Instantly share code, notes, and snippets.

@0test
Last active December 23, 2020 12:13
Show Gist options
  • Save 0test/b7adfebaa293823148f5ab85a5dc6948 to your computer and use it in GitHub Desktop.
Save 0test/b7adfebaa293823148f5ab85a5dc6948 to your computer and use it in GitHub Desktop.
market.yml for Yandex
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
<yml_catalog date="[!mDate? &date=`[*editedon*]`!]">
<shop>
<name>[(site_name)]</name>
<company>[(site_name)]</company>
<url>[(site_url)]</url>
<currencies>
<currency id="RUR" rate="1"/>
</currencies>
<categories>
[!DocLister?
&id=`category`
&parents=`4`
&addWhereList=`c.isfolder=1`
&tpl=`@CODE: <category id="[+id+]">[+pagetitle+]</category>`
!]
</categories>
<offers>
[!DocLister?
&id=`yml`
&prepare=`ya.prepare`
&parents=`4`
&tvPrefix=``
&tvList=`photo,price`
&depth=`4`
&tpl=`yml_tpl`
&showPublishedOnly=`1`
&hideFolders=`1`
&filter=`AND(tv:price:gt:0)`
!]
</offers>
</shop>
</yml_catalog>
<?php
if ($data[price]){
//if ($data[brand]) $data[vendor]="<vendor>".$data[brand]."</vendor>";
//if ($data[articul]) $data[articul]="<vendorCode>".$data[articul]."</vendorCode>";
if( $data['photo'] && count( json_decode($data['photo'])->fieldValue) ){
$data['image'] = json_decode($data['photo'])->fieldValue[0]->image;
$data['image'] = '<picture>[(site_url)]' . $data['image'] .'</picture>';
}
$intro = strip_tags($data['introtext']);
$intro = str_replace('&nbsp',' ',$intro);
$data['introtext'] = $intro;
return $data;
}
<offer id="[+id+]" available="true">
<url>[(site_url)][~[+id+]~]</url>
<price>[+price+]</price>
<currencyId>RUR</currencyId>
<categoryId>[[UltimateParent? &id=`[+id+]` &topLevel=`2`]]</categoryId>
[+image+]
<delivery>false</delivery>
<name>[+pagetitle+]</name>
[+vendor+]
[+articul+]
[+model+]
</offer>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment