Skip to content

[Forwardport] Solve issue #14966 - Disabling product does not remove it from… #16114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
24fb85b
Merge pull request #2 from hitesh-wagento/2.3-develop-PR-port-15734
hitesh-wagento Jun 5, 2018
cc3cdbd
hitesh-wagento Jun 5, 2018
bccf2b2
Merge pull request #3 from hitesh-wagento/2.3-develop-PR-port-15793
hitesh-wagento Jun 5, 2018
46fd094
hitesh-wagento Jun 5, 2018
b3b31f1
Merge pull request #4 from hitesh-wagento/2.3-develop-PR-port-15792
hitesh-wagento Jun 5, 2018
a99ebd0
hitesh-wagento Jun 5, 2018
8d4aa83
Merge pull request #6 from hitesh-wagento/2.3-develop-PR-port-15811
hitesh-wagento Jun 5, 2018
0f23ed7
Add missing table aliases to fields mapping for Customer Group filter…
Jun 5, 2018
0b4443d
Merge pull request #7 from hitesh-wagento/2.3-develop-PR-port-15826
hitesh-wagento Jun 5, 2018
58600f5
Merge pull request #8 from hitesh-wagento/2.3-develop-PR-port-15878
hitesh-wagento Jun 6, 2018
d6f8368
Merge pull request #10 from hitesh-wagento/2.3-develop-PR-port-15914
hitesh-wagento Jun 7, 2018
d9ee180
Attribute set save refactor
AnshuMishra17 Jun 11, 2018
e77424b
code style : 120 line limit
AnshuMishra17 Jun 11, 2018
d4278e4
magento/magento2#15990: Attribute set save admin controller refactor
ihor-sviziev Jun 12, 2018
bad62ef
magento/magento2#15990: Attribute set save admin controller refactor
ihor-sviziev Jun 12, 2018
d942f2b
Merge pull request #13 from hitesh-wagento/2.3-develop-PR-port-15990
hitesh-wagento Jun 12, 2018
e935949
#15205: Postpone instantiation of session config by using a proxy
Jun 7, 2018
69810b7
#15929: Apply changes to HTTP response also to its subclasses
Jun 8, 2018
a8f8831
#15929: Reset changes to HTTP response classes
Jun 8, 2018
a342e9f
Merge pull request #14 from hitesh-wagento/2.3-develop-PR-port-15929
hitesh-wagento Jun 12, 2018
b2ed432
Merge remote-tracking branch 'upstream/2.3-develop' into 2.3-develop
hitesh-wagento Jun 13, 2018
c6f89a1
fixed word typo
ledian-hymetllari Jun 6, 2018
5be1a66
Merge remote-tracking branch 'upstream/2.3-develop' into 2.3-develop
hitesh-wagento Jun 14, 2018
68fbcbf
Merge pull request #15 from hitesh-wagento/2.3-develop-PR-port-15907
hitesh-wagento Jun 14, 2018
6c4fa33
[Solve issue #14966 - Disabling product does not remove it from… #15019]
hitesh-wagento Jun 14, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 36 additions & 11 deletions app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*/
namespace Magento\Catalog\Controller\Adminhtml\Product\Set;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Set
{
/**
Expand All @@ -17,22 +20,49 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Set
* @var \Magento\Framework\Controller\Result\JsonFactory
*/
protected $resultJsonFactory;


/*
* @var \Magento\Eav\Model\Entity\Attribute\SetFactory
*/
private $attributeSetFactory;

/*
* @var \Magento\Framework\Filter\FilterManager
*/
private $filterManager;

/*
* @var \Magento\Framework\Json\Helper\Data
*/
private $jsonHelper;

/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\Registry $coreRegistry
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
* @param \Magento\Eav\Model\Entity\Attribute\SetFactory $attributeSetFactory
* @param \Magento\Framework\Filter\FilterManager $filterManager
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\Registry $coreRegistry,
\Magento\Framework\View\LayoutFactory $layoutFactory,
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
\Magento\Eav\Model\Entity\Attribute\SetFactory $attributeSetFactory = null,
\Magento\Framework\Filter\FilterManager $filterManager = null,
\Magento\Framework\Json\Helper\Data $jsonHelper = null
) {
parent::__construct($context, $coreRegistry);
$this->layoutFactory = $layoutFactory;
$this->resultJsonFactory = $resultJsonFactory;
$this->attributeSetFactory = $attributeSetFactory ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Eav\Model\Entity\Attribute\SetFactory::class);
$this->filterManager = $filterManager ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\Filter\FilterManager::class);
$this->jsonHelper = $jsonHelper ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\Json\Helper\Data::class);
}

/**
Expand Down Expand Up @@ -65,16 +95,12 @@ public function execute()
$isNewSet = $this->getRequest()->getParam('gotoEdit', false) == '1';

/* @var $model \Magento\Eav\Model\Entity\Attribute\Set */
$model = $this->_objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class)
->setEntityTypeId($entityTypeId);

/** @var $filterManager \Magento\Framework\Filter\FilterManager */
$filterManager = $this->_objectManager->get(\Magento\Framework\Filter\FilterManager::class);
$model = $this->attributeSetFactory->create()->setEntityTypeId($entityTypeId);

try {
if ($isNewSet) {
//filter html tags
$name = $filterManager->stripTags($this->getRequest()->getParam('attribute_set_name'));
$name = $this->filterManager->stripTags($this->getRequest()->getParam('attribute_set_name'));
$model->setAttributeSetName(trim($name));
} else {
if ($attributeSetId) {
Expand All @@ -85,11 +111,10 @@ public function execute()
__('This attribute set no longer exists.')
);
}
$data = $this->_objectManager->get(\Magento\Framework\Json\Helper\Data::class)
->jsonDecode($this->getRequest()->getPost('data'));
$data = $this->jsonHelper->jsonDecode($this->getRequest()->getPost('data'));

//filter html tags
$data['attribute_set_name'] = $filterManager->stripTags($data['attribute_set_name']);
$data['attribute_set_name'] = $this->filterManager->stripTags($data['attribute_set_name']);

$model->organizeData($data);
}
Expand Down
46 changes: 36 additions & 10 deletions app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function __construct(
* @param int|null $id
* @return \Magento\Catalog\Model\Indexer\Product\Flat\Action\Row
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Zend_Db_Statement_Exception
*/
public function execute($id = null)
{
Expand All @@ -75,17 +76,42 @@ public function execute($id = null)
if ($tableExists) {
$this->flatItemEraser->removeDeletedProducts($ids, $store->getId());
}
if (isset($ids[0])) {
if (!$tableExists) {
$this->_flatTableBuilder->build(
$store->getId(),
[$ids[0]],
$this->_valueFieldSuffix,
$this->_tableDropSuffix,
false
);

/* @var $status \Magento\Eav\Model\Entity\Attribute */
$status = $this->_productIndexerHelper->getAttribute('status');
$statusTable = $status->getBackend()->getTable();
$statusConditions = [
'store_id IN(0,' . (int)$store->getId() . ')',
'attribute_id = ' . (int)$status->getId(),
'entity_id = ' . (int)$id
];
$select = $this->_connection->select();
$select->from(
$statusTable,
['value']
)->where(
implode(' AND ', $statusConditions)
)->order(
'store_id DESC'
);
$result = $this->_connection->query($select);
$status = $result->fetch(1);
if ($status['value'] == \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) {
if (isset($ids[0])) {
if (!$tableExists) {
$this->_flatTableBuilder->build(
$store->getId(),
[$ids[0]],
$this->_valueFieldSuffix,
$this->_tableDropSuffix,
false
);
}
$this->flatItemWriter->write($store->getId(), $ids[0], $this->_valueFieldSuffix);
}
$this->flatItemWriter->write($store->getId(), $ids[0], $this->_valueFieldSuffix);
}
if ($status['value'] == \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED) {
$this->flatItemEraser->deleteProductsFromStore($id, $store->getId());
}
}
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

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


/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class RowTest extends \PHPUnit\Framework\TestCase
{
/**
Expand Down Expand Up @@ -59,6 +63,8 @@ protected function setUp()
{
$objectManager = new ObjectManager($this);

$attributeTable = 'catalog_product_entity_int';
$statusId = 22;
$this->connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
$this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
$this->resource->expects($this->any())->method('getConnection')
Expand All @@ -68,12 +74,38 @@ protected function setUp()
$this->store = $this->createMock(\Magento\Store\Model\Store::class);
$this->store->expects($this->any())->method('getId')->will($this->returnValue('store_id_1'));
$this->storeManager->expects($this->any())->method('getStores')->will($this->returnValue([$this->store]));
$this->productIndexerHelper = $this->createMock(\Magento\Catalog\Helper\Product\Flat\Indexer::class);
$this->flatItemEraser = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser::class);
$this->flatItemWriter = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer::class);
$this->flatTableBuilder = $this->createMock(
\Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder::class
);
$this->productIndexerHelper = $this->createMock(\Magento\Catalog\Helper\Product\Flat\Indexer::class);
$statusAttributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
->disableOriginalConstructor()
->getMock();
$this->productIndexerHelper->expects($this->any())->method('getAttribute')
->with('status')
->willReturn($statusAttributeMock);
$backendMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class)
->disableOriginalConstructor()
->getMock();
$backendMock->expects($this->any())->method('getTable')->willReturn($attributeTable);
$statusAttributeMock->expects($this->any())->method('getBackend')->willReturn(
$backendMock
);
$statusAttributeMock->expects($this->any())->method('getId')->willReturn($statusId);
$selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
->disableOriginalConstructor()
->getMock();
$this->connection->expects($this->any())->method('select')->willReturn($selectMock);
$selectMock->expects($this->any())->method('from')->with(
$attributeTable,
['value']
)->willReturnSelf();
$selectMock->expects($this->any())->method('where')->willReturnSelf();
$pdoMock = $this->createMock(\Zend_Db_Statement_Pdo::class);
$this->connection->expects($this->any())->method('query')->with($selectMock)->will($this->returnValue($pdoMock));
$pdoMock->expects($this->any())->method('fetch')->will($this->returnValue(['value' => 1]));

$this->model = $objectManager->getObject(
\Magento\Catalog\Model\Indexer\Product\Flat\Action\Row::class,
Expand All @@ -83,7 +115,7 @@ protected function setUp()
'productHelper' => $this->productIndexerHelper,
'flatItemEraser' => $this->flatItemEraser,
'flatItemWriter' => $this->flatItemWriter,
'flatTableBuilder' => $this->flatTableBuilder
'flatTableBuilder' => $this->flatTableBuilder,
]
);
}
Expand Down
12 changes: 6 additions & 6 deletions app/code/Magento/Customer/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -353,19 +353,19 @@
<virtualType name="Magento\Customer\Model\Api\SearchCriteria\CollectionProcessor\GroupFilterProcessor" type="Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor">
<arguments>
<argument name="fieldMapping" xsi:type="array">
<item name="code" xsi:type="string">customer_group_code</item>
<item name="id" xsi:type="string">customer_group_id</item>
<item name="tax_class_name" xsi:type="string">class_name</item>
<item name="code" xsi:type="string">main_table.customer_group_code</item>
<item name="id" xsi:type="string">main_table.customer_group_id</item>
<item name="tax_class_name" xsi:type="string">tax_class_table.class_name</item>
</argument>
</arguments>
</virtualType>
<!-- @api -->
<virtualType name="Magento\Customer\Model\Api\SearchCriteria\CollectionProcessor\GroupSortingProcessor" type="Magento\Framework\Api\SearchCriteria\CollectionProcessor\SortingProcessor">
<arguments>
<argument name="fieldMapping" xsi:type="array">
<item name="code" xsi:type="string">customer_group_code</item>
<item name="id" xsi:type="string">customer_group_id</item>
<item name="tax_class_name" xsi:type="string">class_name</item>
<item name="code" xsi:type="string">main_table.customer_group_code</item>
<item name="id" xsi:type="string">main_table.customer_group_id</item>
<item name="tax_class_name" xsi:type="string">tax_class_table.class_name</item>
</argument>
<argument name="defaultOrders" xsi:type="array">
<item name="id" xsi:type="string">ASC</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@
}
}
}

.opc-wrapper {
.form-login,
.form-shipping-address {
Expand All @@ -307,6 +308,7 @@
padding-bottom: @indent__base;
}
}

.table-checkout-shipping-method {
width: auto;
}
Expand Down Expand Up @@ -346,6 +348,7 @@
}
}
}

.table-checkout-shipping-method {
min-width: 500px;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
& when (@media-common = true) {
.box-tocart {
.action.instant-purchase {
&:extend(.abs-button-l all);
&:extend(.abs-button-responsive all);
.box-tocart {
.action.instant-purchase {
&:extend(.abs-button-l all);
&:extend(.abs-button-responsive all);

&:not(:last-child) {
margin-bottom: 15px;
}
&:not(:last-child) {
margin-bottom: 15px;
}

vertical-align: top;
vertical-align: top;
}
}
}
}

//
// Desktop
// _____________________________________________

.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
.box-tocart {
.action.instant-purchase {
margin-bottom: 0;
margin-right: 1%;
width: 49%;
.box-tocart {
.action.instant-purchase {
margin-bottom: 0;
margin-right: 1%;
width: 49%;
}
}
}
}
Loading