19 private ?
string $detailUrlTemplate =
null;
21 private bool $allowedDetailUrl =
false;
25 $iblockId = (int)\CIBlockElement::GetIBlockByID($productId);
33 return $this->loadFromProductRepository($iblockId, $productId);
43 $iblockId = (int)\CIBlockElement::GetIBlockByID($skuId);
49 $iblockInfo = ServiceContainer::getIblockInfo($iblockId);
57 if ($iblockInfo->getProductIblockId() === $iblockId)
59 $product = $this->loadFromProductRepository($iblockId, $skuId);
62 return $product->getSkuCollection()->getFirst();
67 return $this->loadFromSkuRepository($iblockId, $skuId);
78 $this->allowedDetailUrl = $state;
85 return $this->allowedDetailUrl;
90 $this->detailUrlTemplate = $template;
99 return $this->detailUrlTemplate;
102 private function loadFromProductRepository(
int $iblockId,
int $productId): ?
BaseProduct
104 static $repository =
null;
106 if ($repository ===
null)
108 $repository = ServiceContainer::getProductRepository($iblockId);
119 $repository->setDetailUrlTemplate($urlTemplate);
122 return $repository->getEntityById($productId);
125 private function loadFromSkuRepository(
int $iblockId,
int $skuId): ?BaseSku
127 static $repository =
null;
129 if ($repository ===
null)
131 $repository = ServiceContainer::getSkuRepository($iblockId);
142 $repository->setDetailUrlTemplate($urlTemplate);
145 return $repository->getEntityById($skuId);