Esempio n. 1
0
 public static function checkQuantity($ID, $productFields)
 {
     $checkNeed = isset($productFields['QUANTITY']) || isset($productFields['QUANTITY_TRACE']) || isset($productFields['CAN_BUY_ZERO']);
     if (!$checkNeed) {
         return;
     }
     $productIterator = ProductTable::getList(array('filter' => array('=ID' => $ID), 'select' => array('QUANTITY', 'QUANTITY_TRACE', 'CAN_BUY_ZERO')));
     $product = $productIterator->fetch();
     if ($product) {
         if ($product["QUANTITY_TRACE"] == "Y" && $product['CAN_BUY_ZERO'] == 'N') {
             $linkIterator = LinkTable::getList(array("filter" => array("=LINK_TYPE" => LinkTable::TYPE_IBLOCK_ELEMENT, "=LINK_ID" => $ID, array(array("=BANNER.AUTO_QUANTITY_OFF" => YandexBannerTable::ACTIVE), array("=BANNER.AUTO_QUANTITY_ON" => YandexBannerTable::ACTIVE), 'LOGIC' => "OR")), "select" => array("BANNER_ID", "AUTO_QUANTITY_ON" => "BANNER.AUTO_QUANTITY_ON", "AUTO_QUANTITY_OFF" => "BANNER.AUTO_QUANTITY_OFF")));
             $zeroQuantity = $product['QUANTITY'] <= 0;
             $linkIdMark = array();
             $linkIdUnMark = array();
             while ($link = $linkIterator->fetch()) {
                 $linkIdMark[] = $link["BANNER_ID"];
                 if ($zeroQuantity && $link["AUTO_QUANTITY_ON"] == YandexBannerTable::MARKED || !$zeroQuantity && $link["AUTO_QUANTITY_OFF"] == YandexBannerTable::MARKED) {
                     $linkIdUnMark[] = $link["BANNER_ID"];
                 }
             }
             if (count($linkIdMark) > 0) {
                 if ($zeroQuantity) {
                     YandexBannerTable::markStopped($linkIdMark);
                 } else {
                     YandexBannerTable::markResumed($linkIdMark);
                 }
                 if (count($linkIdUnMark) > 0) {
                     if ($zeroQuantity) {
                         YandexBannerTable::unMarkResumed($linkIdUnMark);
                     } else {
                         YandexBannerTable::unMarkStopped($linkIdUnMark);
                     }
                 }
             }
         }
     }
 }
<?
if(($ID > 0 || $elementId > 0) && Main\Loader::includeModule('iblock'))
{
?>
	<tr>
		<td valign="top"><?=Loc::getMessage("SEO_BANNER_LINKS")?>:</td>
		<td valign="top" colspan="3">
<?
	if($ID > 0)
	{
		$dbRes = Adv\LinkTable::getList(array(
			"filter" => array(
				'=BANNER_ID' => $ID,
			),
			"select" => array(
				"LINK_TYPE", "LINK_ID",
				"ELEMENT_NAME" => "IBLOCK_ELEMENT.NAME",
				"ELEMENT_IBLOCK_ID" => "IBLOCK_ELEMENT.IBLOCK_ID",
				"ELEMENT_IBLOCK_TYPE_ID" => "IBLOCK_ELEMENT.IBLOCK.IBLOCK_TYPE_ID",
				'ELEMENT_IBLOCK_SECTION_ID' => 'IBLOCK_ELEMENT.IBLOCK_SECTION_ID',
			)
		));
	}
	else
	{
		$dbRes = \Bitrix\Iblock\ElementTable::getList(array(
			'filter' => array(
				"=ID" => $elementId,
			),
			'select' => array(
				'LINK_ID' => 'ID',
				'ELEMENT_NAME' => 'NAME',
        echo BeginNote() . Loc::getMessage("SEO_ERROR_NO_CAMPAIGNS", array("#LANGUAGE_ID#" => LANGUAGE_ID)) . EndNote();
    }
    ?>
<a href="/bitrix/admin/seo_search_yandex_direct_edit.php?lang=<?php 
    echo LANGUAGE_ID;
    ?>
&back_url=<?php 
    echo urlencode($APPLICATION->GetCurPageParam('form_element_' . $iblockElementInfo["IBLOCK"]["ID"] . '_active_tab=seo_adv_seo_adv', array('form_element_' . $iblockElementInfo["IBLOCK"]["ID"] . '_active_tab')));
    ?>
"><?php 
    echo Loc::getMessage("SEO_CREATE_NEW_CAMPAIGN");
    ?>
</a>
<?php 
} else {
    $dbRes = Adv\LinkTable::getList(array("filter" => array('LINK_TYPE' => Adv\LinkTable::TYPE_IBLOCK_ELEMENT, 'LINK_ID' => $iblockElementInfo['ID'], "BANNER.ENGINE_ID" => $engine->getId()), "select" => array("BANNER_ID", "BANNER_NAME" => "BANNER.NAME", "BANNER_XML_ID" => "BANNER.XML_ID", "BANNER_CAMPAIGN_ID" => "BANNER.CAMPAIGN_ID")));
    $arBanners = array();
    while ($banner = $dbRes->fetch()) {
        if (!isset($arBanners[$banner['BANNER_CAMPAIGN_ID']])) {
            $arBanners[$banner['BANNER_CAMPAIGN_ID']] = array();
        }
        $arBanners[$banner['BANNER_CAMPAIGN_ID']][] = $banner;
    }
    ?>
<style type="text/css">

span.yandex-delete {
	display: inline-block;
	height: 20px;
	padding-left: 20px;
	line-height: 20px;
Esempio n. 4
0
 protected static function getBannerLinkedProducts($bannerId)
 {
     $linkedProductsList = array();
     $linkedProducts = LinkTable::getList(array('filter' => array('=LINK_TYPE' => LinkTable::TYPE_IBLOCK_ELEMENT, '=BANNER_ID' => $bannerId), 'select' => array('LINK_ID')));
     while ($link = $linkedProducts->fetch()) {
         $linkedProductsList[] = $link['LINK_ID'];
     }
     return $linkedProductsList;
 }