Skip to content

Commit 6e15e7d

Browse files
Merge pull request #1158 from magento-engcom/develop-prs
[EngCom] Public Pull Requests - MAGETWO-69573: Adding logo in media folder #9797 - MAGETWO-69555: Allow for referenceBlock to include template argument #9772 - MAGETWO-69540: Fix for #5897: getIdentities relies on uninitialized collection #9777 - MAGETWO-69533: [BUGFIX][6244] Fix Issue with code label display in cart checkout. #9721 - MAGETWO-69499: Update select.js #9475 - MAGETWO-69451: Replace Zend_Json in the configurable product block test #9753 - MAGETWO-69373: Customer with unique attribute can't be saved #7844 #9712 - MAGETWO-69369: Replace the direct usage of Zend_Json with a call to the Json Help class #9344 - MAGETWO-69085: Do not hardcode product link types #9600 - MAGETWO-69554: Patch to allow multiple filter_url_params to function #9723
2 parents 4f03483 + 894ed7b commit 6e15e7d

File tree

22 files changed

+716
-61
lines changed

22 files changed

+716
-61
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ atlassian*
4848
/pub/media/favicon/*
4949
/pub/media/import/*
5050
!/pub/media/import/.htaccess
51+
/pub/media/logo/*
5152
/pub/media/theme/*
5253
/pub/media/theme_customization/*
5354
!/pub/media/theme_customization/.htaccess

app/code/Magento/Catalog/Block/Product/ProductList/Related.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ protected function _beforeToHtml()
116116
*/
117117
public function getItems()
118118
{
119+
/**
120+
* getIdentities() depends on _itemCollection populated, but it can be empty if the block is hidden
121+
* @see https://github.com/magento/magento2/issues/5897
122+
*/
123+
if (is_null($this->_itemCollection)) {
124+
$this->_prepareData();
125+
}
119126
return $this->_itemCollection;
120127
}
121128

app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ protected function _beforeToHtml()
135135
*/
136136
public function getItemCollection()
137137
{
138+
/**
139+
* getIdentities() depends on _itemCollection populated, but it can be empty if the block is hidden
140+
* @see https://github.com/magento/magento2/issues/5897
141+
*/
142+
if (is_null($this->_itemCollection)) {
143+
$this->_prepareData();
144+
}
138145
return $this->_itemCollection;
139146
}
140147

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ class Helper
7575
*/
7676
private $dateTimeFilter;
7777

78+
/**
79+
* @var \Magento\Catalog\Model\Product\LinkTypeProvider
80+
*/
81+
private $linkTypeProvider;
82+
7883
/**
7984
* Helper constructor.
8085
* @param \Magento\Framework\App\RequestInterface $request
@@ -83,21 +88,25 @@ class Helper
8388
* @param ProductLinks $productLinks
8489
* @param \Magento\Backend\Helper\Js $jsHelper
8590
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
91+
* @param \Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider
8692
*/
8793
public function __construct(
8894
\Magento\Framework\App\RequestInterface $request,
8995
\Magento\Store\Model\StoreManagerInterface $storeManager,
9096
StockDataFilter $stockFilter,
9197
\Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks $productLinks,
9298
\Magento\Backend\Helper\Js $jsHelper,
93-
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
99+
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter,
100+
\Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider = null
94101
) {
95102
$this->request = $request;
96103
$this->storeManager = $storeManager;
97104
$this->stockFilter = $stockFilter;
98105
$this->productLinks = $productLinks;
99106
$this->jsHelper = $jsHelper;
100107
$this->dateFilter = $dateFilter;
108+
$this->linkTypeProvider = $linkTypeProvider ?: \Magento\Framework\App\ObjectManager::getInstance()
109+
->get(\Magento\Catalog\Model\Product\LinkTypeProvider::class);
101110
}
102111

103112
/**
@@ -244,11 +253,17 @@ protected function setProductLinks(\Magento\Catalog\Model\Product $product)
244253

245254
$product = $this->productLinks->initializeLinks($product, $links);
246255
$productLinks = $product->getProductLinks();
247-
$linkTypes = [
248-
'related' => $product->getRelatedReadonly(),
249-
'upsell' => $product->getUpsellReadonly(),
250-
'crosssell' => $product->getCrosssellReadonly()
251-
];
256+
$linkTypes = [];
257+
258+
/** @var \Magento\Catalog\Api\Data\ProductLinkTypeInterface $linkTypeObject */
259+
foreach ($this->linkTypeProvider->getItems() as $linkTypeObject) {
260+
$linkTypes[$linkTypeObject->getName()] = $product->getData($linkTypeObject->getName() . '_readonly');
261+
}
262+
263+
// skip linkTypes that were already processed on initializeLinks plugins
264+
foreach ($productLinks as $productLink) {
265+
unset($linkTypes[$productLink->getLinkType()]);
266+
}
252267

253268
foreach ($linkTypes as $linkType => $readonly) {
254269
if (isset($links[$linkType]) && !$readonly) {

0 commit comments

Comments
 (0)