3namespace Bitrix\Catalog\v2\Sku;
5use Bitrix\Catalog\ProductTable;
6use Bitrix\Catalog\v2\Barcode\BarcodeRepositoryContract;
7use Bitrix\Catalog\v2\BaseCollection;
8use Bitrix\Catalog\v2\BaseEntity;
9use Bitrix\Catalog\v2\Iblock\IblockInfo;
10use Bitrix\Catalog\v2\Image\ImageRepositoryContract;
11use Bitrix\Catalog\v2\MeasureRatio\MeasureRatioRepositoryContract;
12use Bitrix\Catalog\v2\Price\PriceRepositoryContract;
13use Bitrix\Catalog\v2\Product\BaseProduct;
14use Bitrix\Catalog\v2\Property\Property;
15use Bitrix\Catalog\v2\Property\PropertyRepositoryContract;
16use Bitrix\Catalog\v2\StoreProduct\StoreProductRepositoryContract;
17use Bitrix\Main\Result;
51 $this->
setIblockId($this->iblockInfo->getSkuIblockId());
57 $detailUrl = parent::getDetailUrl();
60 if (!$detailUrl && $product = $this->
getParent())
62 $detailUrl = $product->getDetailUrl();
71 parent::setParentCollection($collection);
75 $this->checkProductLink();
85 public function checkProductLink(): self
122 protected function getProductLinkProperty(): ?Property
124 $skuPropertyId = $this->iblockInfo->getSkuPropertyId();
137 $property = $this->getProductLinkProperty();
142 $property->getPropertyValueCollection()->setValues((
string)$productId);
150 $property = $this->getProductLinkProperty();
154 $property->getPropertyValueCollection()->setValues(
null);
162 $isNeedCheckProductLinkAfterSaving = $this->
isNew();
163 $result = parent::saveInternalEntity();
165 if ($isNeedCheckProductLinkAfterSaving &&
$result->isSuccess())
168 if ($product && $this->iblockInfo->getSkuPropertyId())
170 \CIBlockElement::SetPropertyValuesEx(
172 $this->iblockInfo->getSkuIblockId(),
173 [$this->iblockInfo->getSkuPropertyId() => $product->getId()]
177 $this->checkProductLink();
setIblockId(int $iblockId)
unsetProductLinkProperty()
setProductLinkProperty(int $productId)
__construct(IblockInfo $iblockInfo, SkuRepositoryContract $skuRepository, PropertyRepositoryContract $propertyRepository, ImageRepositoryContract $imageRepository, PriceRepositoryContract $priceRepository, MeasureRatioRepositoryContract $measureRatioRepository, BarcodeRepositoryContract $barcodeRepository, StoreProductRepositoryContract $storeProductRepository)
linkProduct(BaseProduct $product)
setParentCollection(?BaseCollection $collection)