Skip to content

Commit b8613e5

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-58806
2 parents 4efad3c + 8931b9c commit b8613e5

File tree

119 files changed

+2482
-391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+2482
-391
lines changed

app/code/Magento/Backend/Block/Widget/Form/Container.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ class Container extends \Magento\Backend\Block\Widget\Container
3737
* @var string
3838
*/
3939
protected $_blockGroup = 'Magento_Backend';
40+
41+
/**
42+
* @var string
43+
*/
44+
const PARAM_BLOCK_GROUP = 'block_group';
45+
46+
/**
47+
* @var string
48+
*/
49+
const PARAM_MODE = 'mode';
4050

4151
/**
4252
* @var string
@@ -49,6 +59,12 @@ class Container extends \Magento\Backend\Block\Widget\Container
4959
protected function _construct()
5060
{
5161
parent::_construct();
62+
if ($this->hasData(self::PARAM_BLOCK_GROUP)) {
63+
$this->_blockGroup = $this->_getData(self::PARAM_BLOCK_GROUP);
64+
}
65+
if ($this->hasData(self::PARAM_MODE)) {
66+
$this->_mode = $this->_getData(self::PARAM_MODE);
67+
}
5268

5369
$this->addButton(
5470
'back',

app/code/Magento/Catalog/Controller/Adminhtml/Category.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ abstract class Category extends \Magento\Backend\App\Action
3131
*/
3232
protected function _initCategory($getRootInstead = false)
3333
{
34-
$categoryId = (int)$this->getRequest()->getParam('id', false);
34+
$categoryId = $this->resolveCategoryId();
3535
$storeId = (int)$this->getRequest()->getParam('store');
3636
$category = $this->_objectManager->create(\Magento\Catalog\Model\Category::class);
3737
$category->setStoreId($storeId);
@@ -62,6 +62,18 @@ protected function _initCategory($getRootInstead = false)
6262
return $category;
6363
}
6464

65+
/**
66+
* Resolve Category Id (from get or from post)
67+
*
68+
* @return int
69+
*/
70+
private function resolveCategoryId()
71+
{
72+
$categoryId = (int)$this->getRequest()->getParam('id', false);
73+
74+
return $categoryId ?: (int)$this->getRequest()->getParam('entity_id', false);
75+
}
76+
6577
/**
6678
* Build response for ajax request
6779
*

app/code/Magento/Catalog/Helper/Product/Compare.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,9 @@ public function getRemoveUrl()
228228
*/
229229
public function getPostDataRemove($product)
230230
{
231-
$listCleanUrl = $this->getEncodedUrl($this->_getUrl('catalog/product_compare'));
232231
$data = [
233-
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $listCleanUrl,
234-
'product' => $product->getId()
232+
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => '',
233+
'product' => $product->getId(),
235234
];
236235
return $this->postHelper->getPostData($this->getRemoveUrl(), $data);
237236
}
@@ -253,9 +252,8 @@ public function getClearListUrl()
253252
*/
254253
public function getPostDataClearList()
255254
{
256-
$refererUrl = $this->_getRequest()->getServer('HTTP_REFERER');
257255
$params = [
258-
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlEncoder->encode($refererUrl)
256+
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => '',
259257
];
260258
return $this->postHelper->getPostData($this->getClearListUrl(), $params);
261259
}

app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Full.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77

88
class Full extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractAction
99
{
10+
/**
11+
* Whether to use main or temporary index table
12+
*
13+
* @var bool
14+
*/
15+
protected $useTempTable = false;
16+
1017
/**
1118
* Refresh entities index
1219
*

app/code/Magento/Catalog/Model/Product.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,7 @@ public function getIdentities()
22742274
$identities[] = self::CACHE_PRODUCT_CATEGORY_TAG . '_' . $categoryId;
22752275
}
22762276
}
2277-
2277+
22782278
if (($this->getOrigData('status') != $this->getData('status')) || $this->isStockStatusChanged()) {
22792279
foreach ($this->getCategoryIds() as $categoryId) {
22802280
$identities[] = self::CACHE_PRODUCT_CATEGORY_TAG . '_' . $categoryId;
@@ -2289,7 +2289,7 @@ public function getIdentities()
22892289

22902290
/**
22912291
* Check whether stock status changed
2292-
*
2292+
*
22932293
* @return bool
22942294
*/
22952295
private function isStockStatusChanged()
@@ -2307,7 +2307,7 @@ private function isStockStatusChanged()
23072307
&& ($stockItem->getIsInStock() != $stockData['is_in_stock'])
23082308
);
23092309
}
2310-
2310+
23112311
/**
23122312
* Reload PriceInfo object
23132313
*

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,22 @@ protected function initializeProductData(array $productData, $createNew)
313313
*/
314314
private function assignProductToWebsites(\Magento\Catalog\Model\Product $product)
315315
{
316+
$websiteIds = $product->getWebsiteIds();
317+
316318
if (!$this->storeManager->hasSingleStore()) {
317-
if ($this->storeManager->getStore()->getCode() == \Magento\Store\Model\Store::ADMIN_CODE) {
318-
$websiteIds = array_keys($this->storeManager->getWebsites());
319-
} else {
320-
$websiteIds = [$this->storeManager->getStore()->getWebsiteId()];
321-
}
319+
$websiteIds = array_unique(
320+
array_merge(
321+
$websiteIds,
322+
[$this->storeManager->getStore()->getWebsiteId()]
323+
)
324+
);
325+
}
322326

323-
$product->setWebsiteIds(array_unique(array_merge($product->getWebsiteIds(), $websiteIds)));
327+
if ($this->storeManager->getStore(true)->getCode() == \Magento\Store\Model\Store::ADMIN_CODE) {
328+
$websiteIds = array_keys($this->storeManager->getWebsites());
324329
}
330+
331+
$product->setWebsiteIds($websiteIds);
325332
}
326333

327334
/**

app/code/Magento/Catalog/Model/ResourceModel/Category.php

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ class Category extends AbstractResource
3333
*/
3434
protected $_categoryProductTable;
3535

36+
/**
37+
* @var array[]
38+
*/
39+
private $entitiesWhereAttributesIs;
40+
3641
/**
3742
* Id of 'is_active' category attribute
3843
*
@@ -573,22 +578,29 @@ public function getIsActiveAttributeId()
573578
*/
574579
public function findWhereAttributeIs($entityIdsFilter, $attribute, $expectedValue)
575580
{
576-
$linkField = $this->getLinkField();
577-
$bind = ['attribute_id' => $attribute->getId(), 'value' => $expectedValue];
578-
$selectEntities = $this->getConnection()->select()->from(
579-
['ce' => $this->getTable('catalog_category_entity')],
580-
['entity_id']
581-
)->joinLeft(
582-
['ci' => $attribute->getBackend()->getTable()],
583-
"ci.{$linkField} = ce.{$linkField} AND attribute_id = :attribute_id",
584-
['value']
585-
)->where(
586-
'ci.value = :value'
587-
)->where(
588-
'ce.entity_id IN (?)',
589-
$entityIdsFilter
590-
);
591-
return $this->getConnection()->fetchCol($selectEntities, $bind);
581+
$entityIdsFilterHash = md5(serialize($entityIdsFilter));
582+
583+
if (!isset($this->entitiesWhereAttributesIs[$entityIdsFilterHash][$attribute->getId()][$expectedValue])) {
584+
$linkField = $this->getLinkField();
585+
$bind = ['attribute_id' => $attribute->getId(), 'value' => $expectedValue];
586+
$selectEntities = $this->getConnection()->select()->from(
587+
['ce' => $this->getTable('catalog_category_entity')],
588+
['entity_id']
589+
)->joinLeft(
590+
['ci' => $attribute->getBackend()->getTable()],
591+
"ci.{$linkField} = ce.{$linkField} AND attribute_id = :attribute_id",
592+
['value']
593+
)->where(
594+
'ci.value = :value'
595+
)->where(
596+
'ce.entity_id IN (?)',
597+
$entityIdsFilter
598+
);
599+
$this->entitiesWhereAttributesIs[$entityIdsFilterHash][$attribute->getId()][$expectedValue] =
600+
$this->getConnection()->fetchCol($selectEntities, $bind);
601+
}
602+
603+
return $this->entitiesWhereAttributesIs[$entityIdsFilterHash][$attribute->getId()][$expectedValue];
592604
}
593605

594606
/**

app/code/Magento/Catalog/Model/ResourceModel/MaxHeapTableSizeProcessor.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
use Magento\Framework\App\ResourceConnection;
99

10+
/**
11+
* @deprecated
12+
*/
1013
class MaxHeapTableSizeProcessor
1114
{
1215
/**

app/code/Magento/Catalog/Plugin/Model/Indexer/Category/Product/MaxHeapTableSizeProcessorOnFullReindex.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
use Magento\Catalog\Model\ResourceModel\MaxHeapTableSizeProcessor;
1111
use Psr\Log\LoggerInterface;
1212

13+
/**
14+
* @deprecated
15+
*/
1316
class MaxHeapTableSizeProcessorOnFullReindex
1417
{
1518
/**

app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,13 @@ public function testGetPostDataRemove()
113113
//Data
114114
$productId = 1;
115115
$removeUrl = 'catalog/product_compare/remove';
116-
$compareListUrl = 'catalog/product_compare';
117116
$postParams = [
118-
Action::PARAM_NAME_URL_ENCODED => strtr(base64_encode($compareListUrl), '+/=', '-_,'),
117+
Action::PARAM_NAME_URL_ENCODED => '',
119118
'product' => $productId
120119
];
121120

122121
//Verification
123-
$this->urlBuilder->expects($this->at(0))
124-
->method('getUrl')
125-
->with($compareListUrl)
126-
->will($this->returnValue($compareListUrl));
127-
$this->urlBuilder->expects($this->at(1))
122+
$this->urlBuilder->expects($this->once())
128123
->method('getUrl')
129124
->with($removeUrl)
130125
->will($this->returnValue($removeUrl));
@@ -159,18 +154,12 @@ public function testGetClearListUrl()
159154
public function testGetPostDataClearList()
160155
{
161156
//Data
162-
$refererUrl = 'home/';
163157
$clearUrl = 'catalog/product_compare/clear';
164158
$postParams = [
165-
Action::PARAM_NAME_URL_ENCODED => strtr(base64_encode($refererUrl), '+/=', '-_,')
159+
Action::PARAM_NAME_URL_ENCODED => ''
166160
];
167161

168162
//Verification
169-
$this->request->expects($this->once())
170-
->method('getServer')
171-
->with('HTTP_REFERER')
172-
->will($this->returnValue($refererUrl));
173-
174163
$this->urlBuilder->expects($this->once())
175164
->method('getUrl')
176165
->with($clearUrl)

0 commit comments

Comments
 (0)