85 $this->_linkCollectionFactory = $linkCollectionFactory;
86 $this->_productCollectionFactory = $productCollectionFactory;
106 $this->setLinkTypeId(self::LINK_TYPE_RELATED);
115 $this->setLinkTypeId(self::LINK_TYPE_UPSELL);
124 $this->setLinkTypeId(self::LINK_TYPE_CROSSSELL);
146 $collection = $this->_productCollectionFactory->create()->setLinkModel($this);
157 $collection = $this->_linkCollectionFactory->create()->setLinkModel($this);
167 if (
$type ===
null) {
168 $type = $this->getLinkTypeId();
170 if (!isset($this->_attributes[
$type])) {
174 return $this->_attributes[
$type];
185 $this->getProductLinkSaveHandler()->execute(\
Magento\Catalog\Api\Data\ProductInterface::class,
$product);
192 private function getProductLinkSaveHandler()
194 if (
null === $this->saveProductLinks) {
$_productCollectionFactory
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Catalog\Model\ResourceModel\Product\Link\CollectionFactory $linkCollectionFactory, \Magento\Catalog\Model\ResourceModel\Product\Link\Product\CollectionFactory $productCollectionFactory, \Magento\CatalogInventory\Helper\Stock $stockHelper, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
saveProductRelations($product)
getAttributes($type=null)
getAttributeTypeTable($type)
const LINK_TYPE_CROSSSELL