130 $this->iblockCatalogData = \CCatalogSku::getInfoByIBlock($this->iblockId);
131 if ($this->iblockCatalogData ===
false)
132 $this->iblockCatalogData = array();
134 if (!$this->simpleIblock)
139 $this->iblockCatalogData[
'USE_SKU'] = ($this->parentIblock ?
'Y' :
'N');
217 if (empty($catalogData))
219 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_EMPTY_DATA');
222 elseif (!is_array($catalogData))
224 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_BAD_DATA');
228 if (!isset($catalogData[
'CATALOG']) || ($catalogData[
'CATALOG'] !=
'Y' && $catalogData[
'CATALOG'] !=
'N'))
229 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_FIELD_CATALOG_IS_ABSENT');
231 if (!isset($catalogData[
'USE_SKU']) || ($catalogData[
'USE_SKU'] !=
'Y' && $catalogData[
'USE_SKU'] !=
'N'))
232 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_FIELD_USE_SKU_IS_ABSENT');
236 if (!isset($catalogData[
'SUBSCRIPTION']) || ($catalogData[
'SUBSCRIPTION'] !=
'Y' && $catalogData[
'SUBSCRIPTION'] !=
'N'))
237 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_FIELD_SUBSCRIPTION_IS_ABSENT');
243 if (!$this->simpleIblock)
245 if ($this->offerIblock && $catalogData[
'CATALOG'] ==
'N')
246 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_OFFERS_ONLY_CATALOG');
247 if ($this->
isEnableRecurring() && $this->parentIblock && $catalogData[
'SUBSCRIPTION'] ==
'Y')
248 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_PARENT_IBLOCK_WITH_SUBSCRIPTION');
249 if ($this->offerIblock && $catalogData[
'USE_SKU'] ==
'Y')
250 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_SKU_WITH_SKU');
258 if ($catalogData[
'USE_SKU'] ==
'Y')
260 if (!isset($catalogData[
'SKU']) || (
int)$catalogData[
'SKU'] <= 0)
261 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_FIELD_SKU_IS_ABSENT');
265 $skuIblockId = (int)$catalogData[
'SKU'];
266 if ($skuIblockId == $this->iblockId)
267 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_SKU_SELF');
272 if (empty($skuIblock))
273 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_SKU_BAD');
280 if (empty($skuSiteList))
281 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_SKU_SITES_EMPTY');
282 elseif ($this->iblockData[
'SITES'] != self::getSiteListString($skuSiteList,
true))
283 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_SKU_SITES_NOT_EQUAL');
289 $skuCatalog = \CCatalogSku::getInfoByIBlock($skuIblockId);
290 if (!self::isSimpleIblock($skuCatalog))
292 if (self::isParentIblock($skuCatalog))
293 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_SKU_WITH_SKU');
294 elseif (self::isOfferIblock($skuCatalog) && $skuCatalog[
'PRODUCT_IBLOCK_ID'] != $this->iblockId)
295 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_SKU_FROM_OTHER_IBLOCK');
302 if (!$this->simpleIblock && $this->offerIblock)
304 if (!isset($catalogData[
'SKU']) || (
int)$catalogData[
'SKU'] <= 0)
305 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_SKU_PARENT_IBLOCK_IS_ABSENT');
306 elseif ($this->iblockCatalogData[
'PRODUCT_IBLOCK_ID'] != $catalogData[
'SKU'])
307 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_SKU_PARENT_IBLOCK_OTHER');
314 if ($catalogData[
'CATALOG'] ==
'Y')
316 if (!isset($catalogData[
'VAT_ID']))
317 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_VAT_ID_IS_ABSENT');
318 elseif ((
int)$catalogData[
'VAT_ID'] < 0)
319 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_BAD_VAT_ID');
320 if (!isset($catalogData[
'YANDEX_EXPORT']))
321 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_YANDEX_EXPORT_IS_ABSENT');
322 elseif ($catalogData[
'YANDEX_EXPORT'] !=
'Y' && $catalogData[
'YANDEX_EXPORT'] !=
'N')
323 $this->errors[] =
Loc::getMessage(
'BX_CAT_HELPER_ADMIN_CATALOGEDIT_ERR_BAD_YANDEX_EXPORT');
329 if ($catalogData[
'CATALOG'] != $this->iblockCatalogData[
'CATALOG'])
331 if ($catalogData[
'CATALOG'] ==
'Y')
334 if (!isset($checkedData[$this->iblockId]))
345 if ($catalogData[
'USE_SKU'] != $this->iblockCatalogData[
'USE_SKU'])
347 if ($catalogData[
'USE_SKU'] ==
'Y')
350 if ($newOffersIBlock || $skuCatalog[
'PRODUCT_IBLOCK_ID'] == 0)
352 if (!isset($checkedData[$skuIblockId]))
353 $checkedData[$skuIblockId] = array();
355 $checkedData[$skuIblockId][
'SKU_PROPERTY_ID'] = 0;
356 if ($newOffersIBlock)
357 $checkedData[$skuIblockId][
'IBLOCK_ID'] = $skuIblockId;
359 unset($newOffersIBlock);
367 $this->updateData = $checkedData;
519 $parentiblockId = (int)$parentiblockId;
520 $offerIblockId = (int)$offerIblockId;
521 if ($parentiblockId <= 0 || $offerIblockId <= 0)
524 $result = \CIBlockPropertyTools::createProperty(
526 \CIBlockPropertyTools::CODE_SKU_LINK,
527 array(
'LINK_IBLOCK_ID' => $parentiblockId)
530 $this->errors = array_merge($this->errors, \CIBlockPropertyTools::getErrors());