Skip to content

Commit f23e935

Browse files
author
Igor Melnikov
committed
Merge branch 'upstream-develop' into MAGETWO-51068-admin-session
2 parents 9dcc8c9 + a5262b0 commit f23e935

File tree

55 files changed

+851
-460
lines changed

Some content is hidden

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

55 files changed

+851
-460
lines changed

app/code/Magento/Backend/App/BackendAppList.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function getCurrentApp()
4444
if ($appName && isset($this->backendApps[$appName])) {
4545
return $this->backendApps[$appName];
4646
}
47+
return null;
4748
}
4849

4950
/**

app/code/Magento/Bundle/Model/ResourceModel/Indexer/Stock.php

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -59,33 +59,27 @@ protected function _prepareBundleOptionStockData($entityIds = null, $usePrimaryT
5959
"bo.parent_id = product.$linkField",
6060
[]
6161
);
62-
$this->_addWebsiteJoinToSelect($select, false);
6362
$status = new \Zend_Db_Expr(
6463
'MAX(' . $connection->getCheckSql('e.required_options = 0', 'i.stock_status', '0') . ')'
6564
);
66-
$select->columns(
67-
'website_id',
68-
'cw'
69-
)->join(
65+
$select->join(
7066
['cis' => $this->getTable('cataloginventory_stock')],
7167
'',
72-
['stock_id']
68+
['website_id', 'stock_id']
7369
)->joinLeft(
7470
['bs' => $this->getTable('catalog_product_bundle_selection')],
7571
'bs.option_id = bo.option_id',
7672
[]
7773
)->joinLeft(
7874
['i' => $idxTable],
79-
'i.product_id = bs.product_id AND i.website_id = cw.website_id AND i.stock_id = cis.stock_id',
75+
'i.product_id = bs.product_id AND i.website_id = cis.website_id AND i.stock_id = cis.stock_id',
8076
[]
8177
)->joinLeft(
8278
['e' => $this->getTable('catalog_product_entity')],
8379
'e.entity_id = bs.product_id',
8480
[]
85-
)->where(
86-
'cw.website_id != 0'
8781
)->group(
88-
['product.entity_id', 'cw.website_id', 'cis.stock_id', 'bo.option_id']
82+
['product.entity_id', 'cis.website_id', 'cis.stock_id', 'bo.option_id']
8983
)->columns(
9084
['option_id' => 'bo.option_id', 'status' => $status]
9185
);
@@ -118,45 +112,19 @@ protected function _prepareBundleOptionStockData($entityIds = null, $usePrimaryT
118112
protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = false)
119113
{
120114
$this->_prepareBundleOptionStockData($entityIds, $usePrimaryTable);
121-
$linkField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField();
122115
$connection = $this->getConnection();
123-
$select = $connection->select()->from(
124-
['e' => $this->getTable('catalog_product_entity')],
125-
['entity_id']
126-
);
127-
$this->_addWebsiteJoinToSelect($select, true);
128-
$this->_addProductWebsiteJoinToSelect($select, 'cw.website_id', 'e.entity_id');
129-
$select->columns(
130-
'cw.website_id'
131-
)->join(
132-
['cis' => $this->getTable('cataloginventory_stock')],
133-
'',
134-
['stock_id']
135-
)->joinLeft(
136-
['cisi' => $this->getTable('cataloginventory_stock_item')],
137-
'cisi.stock_id = cis.stock_id AND cisi.product_id = e.entity_id',
138-
[]
116+
$select = parent::_getStockStatusSelect($entityIds, $usePrimaryTable);
117+
$select->reset(
118+
\Magento\Framework\DB\Select::COLUMNS
119+
)->columns(
120+
['e.entity_id', 'cis.website_id', 'cis.stock_id']
139121
)->joinLeft(
140122
['o' => $this->_getBundleOptionTable()],
141-
'o.entity_id = e.entity_id AND o.website_id = cw.website_id AND o.stock_id = cis.stock_id',
123+
'o.entity_id = e.entity_id AND o.website_id = cis.website_id AND o.stock_id = cis.stock_id',
142124
[]
143125
)->columns(
144126
['qty' => new \Zend_Db_Expr('0')]
145-
)->where(
146-
'cw.website_id != 0'
147-
)->where(
148-
'e.type_id = ?',
149-
$this->getTypeId()
150-
)->group(
151-
['e.entity_id', 'cw.website_id', 'cis.stock_id']
152-
);
153-
154-
// add limitation of status
155-
$condition = $connection->quoteInto(
156-
'=?',
157-
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
158127
);
159-
$this->_addAttributeToSelect($select, 'status', "e.$linkField", 'cs.store_id', $condition);
160128

161129
$statusExpr = $this->getStatusExpression($connection);
162130
$select->columns(

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ protected function getOptionInfo()
458458
'component' => 'Magento_Bundle/js/components/bundle-input-type',
459459
'parentContainer' => 'product_bundle_container',
460460
'selections' => 'bundle_selections',
461-
'targetIndex' => 'is_default',
461+
'isDefaultIndex' => 'is_default',
462+
'userDefinedIndex' => 'selection_can_change_qty',
462463
'dataScope' => 'type',
463464
'label' => __('Input Type'),
464465
'sortOrder' => 20,

app/code/Magento/Bundle/view/adminhtml/web/js/components/bundle-input-type.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,42 @@ define([
2626

2727
if (type !== this.previousType) {
2828
this.previousType = type;
29-
30-
if (type === 'radio') {
31-
this.clearValues();
32-
}
29+
this.processSelections(type === 'radio');
3330
}
3431

3532
this._super();
3633
},
3734

3835
/**
39-
* Clears values in components like this.
36+
* Toggle 'User Defined' column and clears values
37+
* @param {Boolean} isRadio
4038
*/
41-
clearValues: function () {
39+
processSelections: function (isRadio) {
4240
var records = registry.get(this.retrieveParentName(this.parentContainer) + '.' + this.selections),
4341
checkedFound = false;
4442

4543
records.elems.each(function (record) {
4644
record.elems.filter(function (comp) {
47-
return comp.index === this.targetIndex;
45+
return comp.index === this.userDefinedIndex;
4846
}, this).each(function (comp) {
49-
if (comp.checked()) {
50-
if (checkedFound) {
51-
comp.clearing = true;
52-
comp.clear();
53-
comp.clearing = false;
54-
}
55-
56-
checkedFound = true;
57-
}
47+
comp.visible(isRadio);
5848
});
49+
50+
if (isRadio) {
51+
record.elems.filter(function (comp) {
52+
return comp.index === this.isDefaultIndex;
53+
}, this).each(function (comp) {
54+
if (comp.checked()) {
55+
if (checkedFound) {
56+
comp.clearing = true;
57+
comp.clear();
58+
comp.clearing = false;
59+
}
60+
61+
checkedFound = true;
62+
}
63+
});
64+
}
5965
}, this);
6066
},
6167

app/code/Magento/Catalog/Observer/AddCatalogToTopmenuItemsObserver.php renamed to app/code/Magento/Catalog/Plugin/Block/Topmenu.php

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Catalog\Observer;
6+
namespace Magento\Catalog\Plugin\Block;
77

88
use Magento\Catalog\Model\Category;
99
use Magento\Framework\Data\Collection;
1010
use Magento\Framework\Data\Tree\Node;
11-
use Magento\Framework\Event\ObserverInterface;
1211

1312
/**
14-
* Observer that add Categories Tree to Topmenu
13+
* Plugin for top menu block
1514
*/
16-
class AddCatalogToTopmenuItemsObserver implements ObserverInterface
15+
class Topmenu
1716
{
1817
/**
1918
* Catalog category
@@ -38,11 +37,11 @@ class AddCatalogToTopmenuItemsObserver implements ObserverInterface
3837
private $layerResolver;
3938

4039
/**
40+
* Initialize dependencies.
41+
*
4142
* @param \Magento\Catalog\Helper\Category $catalogCategory
42-
* @param \Magento\Catalog\Model\Indexer\Category\Flat\State $categoryFlatState
4343
* @param \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $categoryCollectionFactory
4444
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
45-
* @param \Magento\Catalog\Helper\Category $catalogCategory
4645
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
4746
*/
4847
public function __construct(
@@ -58,26 +57,27 @@ public function __construct(
5857
}
5958

6059
/**
61-
* Checking whether the using static urls in WYSIWYG allowed event
60+
* Build category tree for menu block.
6261
*
63-
* @param \Magento\Framework\Event\Observer $observer
62+
* @param \Magento\Theme\Block\Html\Topmenu $subject
63+
* @param string $outermostClass
64+
* @param string $childrenWrapClass
65+
* @param int $limit
6466
* @return void
67+
* @SuppressWarnings("PMD.UnusedFormalParameter")
6568
*/
66-
public function execute(\Magento\Framework\Event\Observer $observer)
67-
{
68-
$block = $observer->getEvent()->getBlock();
69-
$menuRootNode = $observer->getEvent()->getMenu();
70-
$block->addIdentity(Category::CACHE_TAG);
71-
69+
public function beforeGetHtml(
70+
\Magento\Theme\Block\Html\Topmenu $subject,
71+
$outermostClass = '',
72+
$childrenWrapClass = '',
73+
$limit = 0
74+
) {
7275
$rootId = $this->storeManager->getStore()->getRootCategoryId();
7376
$storeId = $this->storeManager->getStore()->getId();
74-
7577
/** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $collection */
7678
$collection = $this->getCategoryTree($storeId, $rootId);
77-
7879
$currentCategory = $this->getCurrentCategory();
79-
80-
$mapping = [$rootId => $menuRootNode]; // use nodes stack to avoid recursion
80+
$mapping = [$rootId => $subject->getMenu()]; // use nodes stack to avoid recursion
8181
foreach ($collection as $category) {
8282
if (!isset($mapping[$category->getParentId()])) {
8383
continue;
@@ -94,8 +94,28 @@ public function execute(\Magento\Framework\Event\Observer $observer)
9494
$parentCategoryNode->addChild($categoryNode);
9595

9696
$mapping[$category->getId()] = $categoryNode; //add node in stack
97+
}
98+
}
9799

98-
$block->addIdentity(Category::CACHE_TAG . '_' . $category->getId());
100+
/**
101+
* Add list of associated identities to the top menu block for caching purposes.
102+
*
103+
* @param \Magento\Theme\Block\Html\Topmenu $subject
104+
* @return void
105+
*/
106+
public function beforeGetIdentities(\Magento\Theme\Block\Html\Topmenu $subject)
107+
{
108+
$subject->addIdentity(Category::CACHE_TAG);
109+
$rootId = $this->storeManager->getStore()->getRootCategoryId();
110+
$storeId = $this->storeManager->getStore()->getId();
111+
/** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $collection */
112+
$collection = $this->getCategoryTree($storeId, $rootId);
113+
$mapping = [$rootId => $subject->getMenu()]; // use nodes stack to avoid recursion
114+
foreach ($collection as $category) {
115+
if (!isset($mapping[$category->getParentId()])) {
116+
continue;
117+
}
118+
$subject->addIdentity(Category::CACHE_TAG . '_' . $category->getId());
99119
}
100120
}
101121

app/code/Magento/Catalog/Setup/UpgradeData.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,12 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
257257
'frontend_label',
258258
'Small'
259259
);
260+
$categorySetup->updateAttribute(
261+
ProductAttributeInterface::ENTITY_TYPE_CODE,
262+
'image',
263+
'frontend_input_renderer',
264+
null
265+
);
260266

261267
//Design tab
262268
$categorySetup->updateAttribute(
Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
// @codingStandardsIgnoreFile
88

9-
namespace Magento\Catalog\Test\Unit\Observer;
9+
namespace Magento\Catalog\Test\Unit\Plugin\Block;
1010

1111
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1212

13-
class AddCatalogToTopmenuItemsObserverTest extends \PHPUnit_Framework_TestCase
13+
class TopmenuTest extends \PHPUnit_Framework_TestCase
1414
{
1515
/**
16-
* @var \Magento\Catalog\Observer\AddCatalogToTopmenuItemsObserver
16+
* @var \Magento\Catalog\Plugin\Block\Topmenu
1717
*/
18-
protected $_observer;
18+
protected $block;
1919

2020
/**
2121
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Helper\Category
@@ -100,8 +100,8 @@ protected function setUp()
100100
$collection->expects($this->once())->method('getIterator')
101101
->willReturn(new \ArrayIterator([]));
102102

103-
$this->_observer = (new ObjectManager($this))->getObject(
104-
'Magento\Catalog\Observer\AddCatalogToTopmenuItemsObserver',
103+
$this->block = (new ObjectManager($this))->getObject(
104+
\Magento\Catalog\Plugin\Block\Topmenu::class,
105105
[
106106
'catalogCategory' => $this->_catalogCategory,
107107
'menuCategoryData' => $this->menuCategoryData,
@@ -142,23 +142,11 @@ protected function _preparationData()
142142
);
143143

144144
$blockMock = $this->_getCleanMock('\Magento\Theme\Block\Html\Topmenu');
145-
146-
$eventMock = $this->getMock('\Magento\Framework\Event', ['getBlock'], [], '', false);
147-
$eventMock->expects($this->once())
148-
->method('getBlock')
149-
->will($this->returnValue($blockMock));
150-
151-
$observerMock = $this->getMock('\Magento\Framework\Event\Observer', ['getEvent', 'getMenu'], [], '', false);
152-
$observerMock->expects($this->any())
153-
->method('getEvent')
154-
->will($this->returnValue($eventMock));
155-
156-
return $observerMock;
145+
return $blockMock;
157146
}
158147

159148
public function testAddCatalogToTopMenuItems()
160149
{
161-
$observer = $this->_preparationData();
162-
$this->_observer->execute($observer);
150+
$this->block->beforeGetHtml($this->_preparationData());
163151
}
164152
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,7 @@ protected function getHeaderContainerConfig($sortOrder)
319319
'sortOrder' => 20,
320320
'actions' => [
321321
[
322-
'targetName' => static::FORM_NAME . '.' . static::FORM_NAME . '.'
323-
. static::GROUP_CUSTOM_OPTIONS_NAME . '.' . static::GRID_OPTIONS_NAME,
322+
'targetName' => 'ns = ${ $.ns }, index = ' . static::GRID_OPTIONS_NAME,
324323
'actionName' => 'addChild',
325324
]
326325
]

app/code/Magento/Catalog/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
<type name="Magento\Customer\Model\ResourceModel\Visitor">
4747
<plugin name="catalogLog" type="Magento\Catalog\Model\Plugin\Log" />
4848
</type>
49+
<type name="Magento\Theme\Block\Html\Topmenu">
50+
<plugin name="catalogTopmenu" type="Magento\Catalog\Plugin\Block\Topmenu" />
51+
</type>
4952
<type name="Magento\Framework\Mview\View\StateInterface">
5053
<plugin name="setStatusForMview" type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\MviewState" />
5154
</type>

app/code/Magento/Catalog/etc/frontend/events.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,4 @@
1212
<event name="customer_logout">
1313
<observer name="catalog" instance="Magento\Catalog\Observer\Compare\BindCustomerLogoutObserver" shared="false" />
1414
</event>
15-
<event name="page_block_html_topmenu_gethtml_before">
16-
<observer name="catalog_add_topmenu_items" instance="Magento\Catalog\Observer\AddCatalogToTopmenuItemsObserver" />
17-
</event>
1815
</config>

0 commit comments

Comments
 (0)