Skip to content

Commit 90a3a39

Browse files
author
Maksym Aposov
committed
Merge branch 'mainline_develop' into MAGETWO-40002
2 parents cc82454 + 1fb448a commit 90a3a39

File tree

293 files changed

+21805
-5700
lines changed

Some content is hidden

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

293 files changed

+21805
-5700
lines changed

app/code/Magento/Bundle/etc/adminhtml/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
9-
<type name="Magento\Quote\Model\Quote\Item\ToOrderItem">
10-
<plugin name="append_bundle_data_to_order" type="Magento\Bundle\Model\Plugin\QuoteItem"/>
11-
</type>
129
<type name="Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper">
1310
<plugin name="Bundle" type="Magento\Bundle\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Bundle" sortOrder="60" />
1411
</type>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,7 @@
9999
</argument>
100100
</arguments>
101101
</type>
102+
<type name="Magento\Quote\Model\Quote\Item\ToOrderItem">
103+
<plugin name="append_bundle_data_to_order" type="Magento\Bundle\Model\Plugin\QuoteItem"/>
104+
</type>
102105
</config>

app/code/Magento/Bundle/etc/frontend/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
9-
<type name="Magento\Quote\Model\Quote\Item\ToOrderItem">
10-
<plugin name="append_bundle_data_to_order" type="Magento\Bundle\Model\Plugin\QuoteItem"/>
11-
</type>
129
<type name="Magento\Catalog\Helper\Product\ConfigurationPool">
1310
<arguments>
1411
<argument name="instancesByType" xsi:type="array">

app/code/Magento/Catalog/Controller/Adminhtml/Product/MassDelete.php

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,69 +6,58 @@
66
*/
77
namespace Magento\Catalog\Controller\Adminhtml\Product;
88

9-
use Magento\Catalog\Model\Resource\Product\Collection;
109
use Magento\Framework\Controller\ResultFactory;
10+
use Magento\Catalog\Controller\Adminhtml\Product\Builder;
11+
use Magento\Backend\App\Action\Context;
12+
use Magento\Ui\Component\MassAction\Filter;
13+
use Magento\Catalog\Model\Resource\Product\CollectionFactory;
1114

1215
class MassDelete extends \Magento\Catalog\Controller\Adminhtml\Product
1316
{
1417
/**
15-
* Field id
18+
* Massactions filter
19+
*
20+
* @var Filter
1621
*/
17-
const ID_FIELD = 'entity_id';
22+
protected $filter;
1823

1924
/**
20-
* Redirect url
25+
* @var CollectionFactory
2126
*/
22-
const REDIRECT_URL = 'catalog/*/index';
27+
protected $collectionFactory;
2328

2429
/**
25-
* Resource collection
26-
*
27-
* @var string
30+
* @param Context $context
31+
* @param Builder $productBuilder
32+
* @param Filter $filter
33+
* @param CollectionFactory $collectionFactory
2834
*/
29-
protected $collection = 'Magento\Catalog\Model\Resource\Product\Collection';
35+
public function __construct(
36+
Context $context,
37+
Builder $productBuilder,
38+
Filter $filter,
39+
CollectionFactory $collectionFactory
40+
) {
41+
$this->filter = $filter;
42+
$this->collectionFactory = $collectionFactory;
43+
parent::__construct($context, $productBuilder);
44+
}
3045

3146
/**
3247
* @return \Magento\Backend\Model\View\Result\Redirect
3348
*/
3449
public function execute()
3550
{
36-
$selected = $this->getRequest()->getParam('selected');
37-
$excluded = $this->getRequest()->getParam('excluded');
38-
39-
$collection = $this->_objectManager->create($this->collection);
40-
try {
41-
if (!empty($excluded)) {
42-
$collection->addFieldToFilter(static::ID_FIELD, ['nin' => $excluded]);
43-
$this->massAction($collection);
44-
} elseif (!empty($selected)) {
45-
$collection->addFieldToFilter(static::ID_FIELD, ['in' => $selected]);
46-
$this->massAction($collection);
47-
} else {
48-
$this->messageManager->addError(__('Please select product(s).'));
49-
}
50-
} catch (\Exception $e) {
51-
$this->messageManager->addError($e->getMessage());
52-
}
53-
54-
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
55-
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
56-
return $resultRedirect->setPath(static::REDIRECT_URL);
57-
}
58-
59-
/**
60-
* Cancel selected orders
61-
*
62-
* @param Collection $collection
63-
* @return void
64-
*/
65-
protected function massAction($collection)
66-
{
67-
$count = 0;
51+
$collection = $this->filter->getCollection($this->collectionFactory->create());
52+
$productDeleted = 0;
6853
foreach ($collection->getItems() as $product) {
6954
$product->delete();
70-
++$count;
55+
$productDeleted++;
7156
}
72-
$this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $count));
57+
$this->messageManager->addSuccess(
58+
__('A total of %1 record(s) have been deleted.', $productDeleted)
59+
);
60+
61+
return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('catalog/*/index');
7362
}
7463
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
3434
*/
3535
const MAIN_TABLE_ALIAS = 'e';
3636

37+
/**
38+
* @var string
39+
*/
40+
protected $_idFieldName = 'entity_id';
41+
3742
/**
3843
* Catalog Product Flat is enabled cache per store
3944
*

app/code/Magento/Catalog/Ui/DataProvider/Product/AddStoreFieldToCollection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function __construct(StoreManagerInterface $storeManager)
3434
public function addFilter(Collection $collection, $field, $condition = null)
3535
{
3636
if (isset($condition['eq']) && $condition['eq']) {
37+
/** @var \Magento\Catalog\Model\Resource\Product\Collection $collection */
3738
$collection->addStoreFilter($this->storeManager->getStore($condition['eq']));
3839
}
3940
}

app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,6 @@ public function __construct(
5757
$this->addFilterStrategies = $addFilterStrategies;
5858
}
5959

60-
/**
61-
* Get collection
62-
*
63-
* @return \Magento\Catalog\Model\Resource\Product\Collection
64-
*/
65-
protected function getCollection()
66-
{
67-
return $this->collection;
68-
}
69-
7060
/**
7161
* Get data
7262
*
@@ -104,12 +94,17 @@ public function addField($field, $alias = null)
10494
/**
10595
* {@inheritdoc}
10696
*/
107-
public function addFilter($condition, $field = null, $type = 'regular')
97+
public function addFilter(\Magento\Framework\Api\Filter $filter)
10898
{
109-
if (isset($this->addFilterStrategies[$field])) {
110-
$this->addFilterStrategies[$field]->addFilter($this->getCollection(), $field, $condition);
99+
if (isset($this->addFilterStrategies[$filter->getField()])) {
100+
$this->addFilterStrategies[$filter->getField()]
101+
->addFilter(
102+
$this->getCollection(),
103+
$filter->getField(),
104+
[$filter->getConditionType() => $filter->getValue()]
105+
);
111106
} else {
112-
parent::addFilter($condition, $field);
107+
parent::addFilter($filter);
113108
}
114109
}
115110
}

app/code/Magento/Cms/Controller/Adminhtml/AbstractMassDelete.php

Lines changed: 0 additions & 145 deletions
This file was deleted.

0 commit comments

Comments
 (0)