Skip to content

Commit

Permalink
Merge pull request #1174 from magento-engcom/2.1-develop-prs
Browse files Browse the repository at this point in the history
[EngCom] Public Pull Requests - 2.1
 - MAGETWO-69665: Backport of MAGETWO-59089 for Magento 2.1: Magento 2.1.1 Problem with change currency #9841
 - MAGETWO-69543: Fixes regression bug introduced in Magento 2.1.6 where the layered navigation options are sometimes being cached using the wrong store id. #9704
 - MAGETWO-69151: Do not hardcode product link types [2.1 backport] #9601
 - MAGETWO-69691: Travis build failures because the job exceeded the maximum time limit for jobs - 2.1-develop
  • Loading branch information
ishakhsuvarov authored Jun 7, 2017
2 parents 118a197 + 7294054 commit 0c6c8a2
Show file tree
Hide file tree
Showing 6 changed files with 321 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ class Helper
* @var \Magento\Framework\Stdlib\DateTime\Filter\DateTime
*/
private $dateTimeFilter;

/**
* @var \Magento\Catalog\Model\Product\LinkTypeProvider
*/
private $linkTypeProvider;

/**
* Helper constructor.
Expand All @@ -83,21 +88,25 @@ class Helper
* @param ProductLinks $productLinks
* @param \Magento\Backend\Helper\Js $jsHelper
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
* @param \Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider
*/
public function __construct(
\Magento\Framework\App\RequestInterface $request,
\Magento\Store\Model\StoreManagerInterface $storeManager,
StockDataFilter $stockFilter,
\Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks $productLinks,
\Magento\Backend\Helper\Js $jsHelper,
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter,
\Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider = null
) {
$this->request = $request;
$this->storeManager = $storeManager;
$this->stockFilter = $stockFilter;
$this->productLinks = $productLinks;
$this->jsHelper = $jsHelper;
$this->dateFilter = $dateFilter;
$this->linkTypeProvider = $linkTypeProvider ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Catalog\Model\Product\LinkTypeProvider::class);
}

/**
Expand Down Expand Up @@ -247,11 +256,17 @@ protected function setProductLinks(\Magento\Catalog\Model\Product $product)

$product = $this->productLinks->initializeLinks($product, $links);
$productLinks = $product->getProductLinks();
$linkTypes = [
'related' => $product->getRelatedReadonly(),
'upsell' => $product->getUpsellReadonly(),
'crosssell' => $product->getCrosssellReadonly()
];
$linkTypes = [];

/** @var \Magento\Catalog\Api\Data\ProductLinkTypeInterface $linkTypeObject */
foreach ($this->linkTypeProvider->getItems() as $linkTypeObject) {
$linkTypes[$linkTypeObject->getName()] = $product->getData($linkTypeObject->getName() . '_readonly');
}

// skip linkTypes that were already processed on initializeLinks plugins
foreach ($productLinks as $productLink) {
unset($linkTypes[$productLink->getLinkType()]);
}

foreach ($linkTypes as $linkType => $readonly) {
if (isset($links[$linkType]) && !$readonly) {
Expand Down
Loading

0 comments on commit 0c6c8a2

Please sign in to comment.