25 $arPropertyMap = array();
26 $arSelectedPropTypes = array(
'S',
'N',
'L',
'E',
'G');
27 $this->arSelectOfferProps = array();
28 $arOffers = \CCatalogSku::GetInfoByProductIBlock($this->iBlockId);
33 $this->intOfferIBlockID =
$arOffers[
'IBLOCK_ID'];
34 $rsOfferIBlocks = \CIBlock::GetByID($this->intOfferIBlockID);
36 if (!$this->arOfferIBlock = $rsOfferIBlocks->Fetch())
37 throw new SystemException(
"Bad offers iBlock ID (".__CLASS__.
"::".__METHOD__.
")");
39 $rsProps = \CIBlockProperty::GetList(
40 array(
'SORT' =>
'ASC',
'NAME' =>
'ASC'),
41 array(
'IBLOCK_ID' => $this->intOfferIBlockID,
'ACTIVE' =>
'Y',
'CHECK_PERMISSIONS' =>
'N')
44 while ($arProp = $rsProps->Fetch())
46 $arProp[
'ID'] = (int)$arProp[
'ID'];
48 if (
$arOffers[
'SKU_PROPERTY_ID'] != $arProp[
'ID'])
50 $arProp[
'USER_TYPE'] = (string)$arProp[
'USER_TYPE'];
51 $arProp[
'CODE'] = (string)$arProp[
'CODE'];
52 $this->arIblock[
'OFFERS_PROPERTY'][$arProp[
'ID']] = $arProp;
53 $this->arProperties[$arProp[
'ID']] = $arProp;
55 if (in_array($arProp[
'PROPERTY_TYPE'], $arSelectedPropTypes))
56 $this->arSelectOfferProps[] = $arProp[
'ID'];
58 if ($arProp[
'CODE'] !==
'')
60 foreach ($this->arIblock[
'PROPERTY'] as &$arMainProp)
62 if ($arMainProp[
'CODE'] == $arProp[
'CODE'])
64 $arPropertyMap[$arProp[
'ID']] = $arMainProp[
'CODE'];
69 if (isset($arMainProp))
75 $this->arOfferIBlock[
'LID'] = $this->arIblock[
'LID'];
77 $this->arOfferIBlock[
'PROPERTY'] = array();
79 $rsProps = \CIBlockProperty::GetList(
80 array(
'SORT' =>
'ASC',
'NAME' =>
'ASC'),
81 array(
'IBLOCK_ID' => $this->intOfferIBlockID,
'ACTIVE' =>
'Y',
'CHECK_PERMISSIONS' =>
'N')
84 while ($arProp = $rsProps->Fetch())
87 $arProp[
'ID'] = (int)$arProp[
'ID'];
88 $arProp[
'USER_TYPE'] = (string)$arProp[
'USER_TYPE'];
89 $arProp[
'CODE'] = (string)$arProp[
'CODE'];
90 $this->arOfferIBlock[
'PROPERTY'][$arProp[
'ID']] = $arProp;
98 $arOffersSelectKeys = array(
99 YANDEX_SKU_EXPORT_ALL,
100 YANDEX_SKU_EXPORT_MIN_PRICE,
101 YANDEX_SKU_EXPORT_PROP,
104 $arCondSelectProp = array(
113 if (is_array($this->arOfferIBlock) && !empty($this->arOfferIBlock))
115 if (empty($this->xmlData[
'SKU_EXPORT']))
123 if (YANDEX_SKU_EXPORT_PROP ==
$arSKUExport[
'SKU_EXPORT_COND'])
128 if (empty(
$arSKUExport[
'SKU_PROP_COND'][
'PROP_ID']) || !in_array(
$arSKUExport[
'SKU_PROP_COND'][
'PROP_ID'],$this->arSelectOfferProps))
131 if (empty(
$arSKUExport[
'SKU_PROP_COND'][
'COND']) || !in_array(
$arSKUExport[
'SKU_PROP_COND'][
'COND'],$arCondSelectProp))
132 throw new SystemException(
"YANDEX_SKU_EXPORT_ERR_PROPERTY_COND_ABSENT");
137 throw new SystemException(
"YANDEX_SKU_EXPORT_ERR_PROPERTY_VALUES_ABSENT");
147 $strOfferTemplateURL =
'';
149 if (!empty($this->arSKUExport[
'SKU_URL_TEMPLATE_TYPE']))
151 switch($this->arSKUExport[
'SKU_URL_TEMPLATE_TYPE'])
153 case YANDEX_SKU_TEMPLATE_PRODUCT:
154 $strOfferTemplateURL =
'#PRODUCT_URL#';
156 case YANDEX_SKU_TEMPLATE_CUSTOM:
157 if (!empty($this->arSKUExport[
'SKU_URL_TEMPLATE']))
158 $strOfferTemplateURL = $this->arSKUExport[
'SKU_URL_TEMPLATE'];
160 case YANDEX_SKU_TEMPLATE_OFFERS:
162 $strOfferTemplateURL =
'';
167 return $strOfferTemplateURL;
172 $arOfferSelect = array(
"ID",
"LID",
"IBLOCK_ID",
"NAME",
"PREVIEW_PICTURE",
"PREVIEW_TEXT",
173 "PREVIEW_TEXT_TYPE",
"DETAIL_PICTURE",
"DETAIL_PAGE_URL",
"DETAIL_TEXT");
175 $arOfferFilter = array(
'IBLOCK_ID' => $this->intOfferIBlockID,
'PROPERTY_'.$this->arOffers[
'SKU_PROPERTY_ID'] => 0,
176 "ACTIVE" =>
"Y",
"ACTIVE_DATE" =>
"Y");
178 if($this->onlyAvailableElements)
179 $arOfferFilter[
"CATALOG_AVAILABLE"] =
"Y";
181 if (YANDEX_SKU_EXPORT_PROP == $this->arSKUExport[
'SKU_EXPORT_COND'])
186 if ($this->arSKUExport[
'SKU_PROP_COND'][
'COND'] ==
'NONZERO' || $this->arSKUExport[
'SKU_PROP_COND'][
'COND'] ==
'NONEQUAL')
189 $strExportKey .=
'PROPERTY_'.$this->arSKUExport[
'SKU_PROP_COND'][
'PROP_ID'];
191 if ($this->arSKUExport[
'SKU_PROP_COND'][
'COND'] ==
'EQUAL' || $this->arSKUExport[
'SKU_PROP_COND'][
'COND'] ==
'NONEQUAL')
192 $mxValues = $this->arSKUExport[
'SKU_PROP_COND'][
'VALUES'];
194 $arOfferFilter[$strExportKey] = $mxValues;
197 $arOfferFilter[
'PROPERTY_'.$this->arOffers[
'SKU_PROPERTY_ID']] = $itemId;
198 return \CIBlockElement::GetList(array(),$arOfferFilter,
false,
false,$arOfferSelect);
256 while ($obOfferItem = $rsOfferItems->GetNextElement())
258 $arOfferItem = $obOfferItem->GetFields();
259 $arOfferItem[
"PRICES"] = $this->
getPrices($obOfferItem[
"ID"], $this->arOfferIBlock[
'LID']);
261 if ($arOfferItem[
"PRICES"][
"MIN"] <= 0)
266 $dblAllMinPrice = $arOfferItem[
"PRICES"][
"MIN"];
271 if ($dblAllMinPrice > $arOfferItem[
"PRICES"][
"MIN_RUB"])
272 $dblAllMinPrice = $arOfferItem[
"PRICES"][
"MIN_RUB"];
278 $arOfferItem[
'PROPERTIES'] = $this->
getItemProps($obOfferItem, $arItem);
279 $arCurrentOffer = $arOfferItem;
281 if (!empty($arCurrentOffer) && $arCurrentOffer[
"PRICES"][
"MIN"] > 0)
283 $arOfferItem = $arCurrentOffer;
288 $arOfferItem = array();