Есть необходимость выгружать в яндекс.маркет только тот товар, который есть в наличии.
Есть код модуля выгрузки, где тут что поправить, чтобы выгружались в маркет только товар со статусом - в наличии?
<?
require_once(__DIR__."/. ./.."."/bitrix/modules/main/include/prolog_before.php");
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
if(!CModule::IncludeModule('iblock') || !CModule::IncludeModule('catalog') || !CModule::IncludeModule('sale')) die();
function ConvertToXML($string){
return strip_tags(str_replace([" ","\"","&",">","<","'"],[" ",""","&",">","<","'"],$string));
}
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
<yml_catalog date="<?=date("Y-m-d H:i")?>">
<shop>
<name>SB-SMART</name>
<company>SB-SMART</company>
<url>;
<platform>1C-Bitrix</platform>
<currencies>
<?
$lcur = CCurrency::GetList(($by="currency"), ($order1="asc"));
$str = "";
while($lcur_res = $lcur->Fetch()){
if($lcur_res["BASE"] == "Y"){
?><?="\t\t";?><currency id="<?=$lcur_res["CURRENCY"];?>" rate="<?=$lcur_res["AMOUNT"]/$lcur_res["AMOUNT_CNT"];?>" /><?
}else{
$str .= "\n\t\t<currency id=\"".$lcur_res["CURRENCY"]."\" rate=\"".number_format($lcur_res["AMOUNT"]/$lcur_res["AMOUNT_CNT"],5,".","")."\" />";
}
}
echo $str."\n";
?>
</currencies>
<categories>
<?
$res = CIBlockSection::GetList(["section" => "ASC"],["IBLOCK_ID" => 13],false,["ID","IBLOCK_SECTION_ID","NAME"]);
while($arRes = $res->Fetch()){
?><?="\t\t";?><category id="<?=$arRes["ID"];?>"<?=((IntVal($arRes["IBLOCK_SECTION_ID"]) > 0)?" parentId=\"".$arRes["IBLOCK_SECTION_ID"]."\"":"");?>><?=$arRes["NAME"];?></category><?="\n";?><?
}
?>
</categories>
<delivery-options>
<option cost="340" days="1-3"/>
</delivery-options>
<offers>
<?
$db_res = CIBlockElement::GetList(array("ID" => "DESC"),array("IBLOCK_ID" => 13,"ACTIVE" => "Y"),false,false,["ID","NAME","DETAIL_PAGE_URL","IBLOCK_SECTION_ID","DETAIL_PICTURE","PREVIEW_PICTURE","PREVIEW_TEXT","DETAIL_TEXT","PROPERTY_NOT_IN_STOCK"]);
while($arProduct = $db_res->GetNext()){
$dbPrice = CPrice::GetList([],array("PRODUCT_ID" => $arProduct["ID"]),false,false,array("ID","PRICE", "CURRENCY"));
$arPriceAr = false;
while ($arPrice = $dbPrice->Fetch()){
$arPriceAr = $arPrice;
$arDiscounts = CCatalogDiscount::GetDiscountByPrice($arPrice["ID"]);
$discountPrice = CCatalogProduct::CountPriceWithDiscount($arPrice["PRICE"],$arPrice["CURRENCY"],$arDiscounts);
$arPriceAr["DISCOUNT_PRICE"] = $discountPrice;
}
//var_dump($arPrice);
if(IntVal($arPriceAr["PRICE"]) == 0) continue;
?>
<offer id="<?=$arProduct["ID"];?>" available="<?=((isset($arProduct["PROPERTY_NOT_IN_STOCK_VALUE"]) && $arProduct["PROPERTY_NOT_IN_STOCK_VALUE"] != false)?"false":"true")?>">
<url>;
<?
if(isset($arPriceAr["DISCOUNT_PRICE"]) && $arPriceAr["DISCOUNT_PRICE"] > 0 && $arPriceAr["DISCOUNT_PRICE"] < $arPriceAr["PRICE"]){
?><price><?=IntVal($arPriceAr["DISCOUNT_PRICE"]);?></price>
<oldprice><?=IntVal($arPriceAr["PRICE"]);?></oldprice><?="\n";?><?
}else{
?><price><?=IntVal($arPriceAr["PRICE"]);?></price><?
}
?>
<currencyId><?=$arPriceAr["CURRENCY"];?></currencyId>
<categoryId><?=$arProduct["IBLOCK_SECTION_ID"]?></categoryId>
<?
if(IntVal($arProduct["DETAIL_PICTURE"]) > 0 || IntVal($arProduct["PREVIEW_PICTURE"]) > 0){
?><picture> > 0)?CFile::GetPath($arProduct["DETAIL_PICTURE"]):CFile::GetPath($arProduct["PREVIEW_PICTURE"]));?></picture><?="\n";?><?
}
?>
<delivery>true</delivery>
<delivery-options>
<option cost="340" days="<?=((isset($arProduct["PROPERTY_NOT_IN_STOCK_VALUE"]) && $arProduct["PROPERTY_NOT_IN_STOCK_VALUE"] != false)?"32":"1-3")?>"/>
</delivery-options>
<name><?=$arProduct["NAME"]?></name>
<description><?=ConvertToXML(((strlen($arProduct["PREVIEW_TEXT"]) > 0)?$arProduct["PREVIEW_TEXT"]:$arProduct["DETAIL_TEXT"]))?></description>
<sales_notes>Гарантия лучшей цены!Мин.заказ - 4000р.;Возможна предоплата<?=((isset($arProduct["PROPERTY_NOT_IN_STOCK_VALUE"]) && $arProduct["PROPERTY_NOT_IN_STOCK_VALUE"] != false)?"Возможна Предоплата":"")?></sales_notes>
</offer>
<?
}
?>
</offers>
</shop>
</yml_catalog>
Есть код модуля выгрузки, где тут что поправить, чтобы выгружались в маркет только товар со статусом - в наличии?
<?
require_once(__DIR__."/. ./.."."/bitrix/modules/main/include/prolog_before.php");
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
if(!CModule::IncludeModule('iblock') || !CModule::IncludeModule('catalog') || !CModule::IncludeModule('sale')) die();
function ConvertToXML($string){
return strip_tags(str_replace([" ","\"","&",">","<","'"],[" ",""","&",">","<","'"],$string));
}
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
<yml_catalog date="<?=date("Y-m-d H:i")?>">
<shop>
<name>SB-SMART</name>
<company>SB-SMART</company>
<url>;
<platform>1C-Bitrix</platform>
<currencies>
<?
$lcur = CCurrency::GetList(($by="currency"), ($order1="asc"));
$str = "";
while($lcur_res = $lcur->Fetch()){
if($lcur_res["BASE"] == "Y"){
?><?="\t\t";?><currency id="<?=$lcur_res["CURRENCY"];?>" rate="<?=$lcur_res["AMOUNT"]/$lcur_res["AMOUNT_CNT"];?>" /><?
}else{
$str .= "\n\t\t<currency id=\"".$lcur_res["CURRENCY"]."\" rate=\"".number_format($lcur_res["AMOUNT"]/$lcur_res["AMOUNT_CNT"],5,".","")."\" />";
}
}
echo $str."\n";
?>
</currencies>
<categories>
<?
$res = CIBlockSection::GetList(["section" => "ASC"],["IBLOCK_ID" => 13],false,["ID","IBLOCK_SECTION_ID","NAME"]);
while($arRes = $res->Fetch()){
?><?="\t\t";?><category id="<?=$arRes["ID"];?>"<?=((IntVal($arRes["IBLOCK_SECTION_ID"]) > 0)?" parentId=\"".$arRes["IBLOCK_SECTION_ID"]."\"":"");?>><?=$arRes["NAME"];?></category><?="\n";?><?
}
?>
</categories>
<delivery-options>
<option cost="340" days="1-3"/>
</delivery-options>
<offers>
<?
$db_res = CIBlockElement::GetList(array("ID" => "DESC"),array("IBLOCK_ID" => 13,"ACTIVE" => "Y"),false,false,["ID","NAME","DETAIL_PAGE_URL","IBLOCK_SECTION_ID","DETAIL_PICTURE","PREVIEW_PICTURE","PREVIEW_TEXT","DETAIL_TEXT","PROPERTY_NOT_IN_STOCK"]);
while($arProduct = $db_res->GetNext()){
$dbPrice = CPrice::GetList([],array("PRODUCT_ID" => $arProduct["ID"]),false,false,array("ID","PRICE", "CURRENCY"));
$arPriceAr = false;
while ($arPrice = $dbPrice->Fetch()){
$arPriceAr = $arPrice;
$arDiscounts = CCatalogDiscount::GetDiscountByPrice($arPrice["ID"]);
$discountPrice = CCatalogProduct::CountPriceWithDiscount($arPrice["PRICE"],$arPrice["CURRENCY"],$arDiscounts);
$arPriceAr["DISCOUNT_PRICE"] = $discountPrice;
}
//var_dump($arPrice);
if(IntVal($arPriceAr["PRICE"]) == 0) continue;
?>
<offer id="<?=$arProduct["ID"];?>" available="<?=((isset($arProduct["PROPERTY_NOT_IN_STOCK_VALUE"]) && $arProduct["PROPERTY_NOT_IN_STOCK_VALUE"] != false)?"false":"true")?>">
<url>;
<?
if(isset($arPriceAr["DISCOUNT_PRICE"]) && $arPriceAr["DISCOUNT_PRICE"] > 0 && $arPriceAr["DISCOUNT_PRICE"] < $arPriceAr["PRICE"]){
?><price><?=IntVal($arPriceAr["DISCOUNT_PRICE"]);?></price>
<oldprice><?=IntVal($arPriceAr["PRICE"]);?></oldprice><?="\n";?><?
}else{
?><price><?=IntVal($arPriceAr["PRICE"]);?></price><?
}
?>
<currencyId><?=$arPriceAr["CURRENCY"];?></currencyId>
<categoryId><?=$arProduct["IBLOCK_SECTION_ID"]?></categoryId>
<?
if(IntVal($arProduct["DETAIL_PICTURE"]) > 0 || IntVal($arProduct["PREVIEW_PICTURE"]) > 0){
?><picture> > 0)?CFile::GetPath($arProduct["DETAIL_PICTURE"]):CFile::GetPath($arProduct["PREVIEW_PICTURE"]));?></picture><?="\n";?><?
}
?>
<delivery>true</delivery>
<delivery-options>
<option cost="340" days="<?=((isset($arProduct["PROPERTY_NOT_IN_STOCK_VALUE"]) && $arProduct["PROPERTY_NOT_IN_STOCK_VALUE"] != false)?"32":"1-3")?>"/>
</delivery-options>
<name><?=$arProduct["NAME"]?></name>
<description><?=ConvertToXML(((strlen($arProduct["PREVIEW_TEXT"]) > 0)?$arProduct["PREVIEW_TEXT"]:$arProduct["DETAIL_TEXT"]))?></description>
<sales_notes>Гарантия лучшей цены!Мин.заказ - 4000р.;Возможна предоплата<?=((isset($arProduct["PROPERTY_NOT_IN_STOCK_VALUE"]) && $arProduct["PROPERTY_NOT_IN_STOCK_VALUE"] != false)?"Возможна Предоплата":"")?></sales_notes>
</offer>
<?
}
?>
</offers>
</shop>
</yml_catalog>