Skip to content

Commit 70f8114

Browse files
Merge pull request #8354 from magento-gl/spartans_pr_13062023
[Spartans] Bugfix Delivery
2 parents eefe406 + 8b0da1c commit 70f8114

File tree

7 files changed

+218
-22
lines changed

7 files changed

+218
-22
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Product.php

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,26 @@
1111
*/
1212
namespace Magento\Catalog\Block\Adminhtml\Category\Tab;
1313

14+
use Magento\Backend\Block\Template\Context;
1415
use Magento\Backend\Block\Widget\Grid;
1516
use Magento\Backend\Block\Widget\Grid\Column;
1617
use Magento\Backend\Block\Widget\Grid\Extended;
18+
use Magento\Backend\Helper\Data;
1719
use Magento\Catalog\Model\Product\Attribute\Source\Status;
1820
use Magento\Catalog\Model\Product\Visibility;
21+
use Magento\Catalog\Model\ProductFactory;
1922
use Magento\Framework\App\ObjectManager;
23+
use Magento\Framework\Registry;
2024

21-
class Product extends \Magento\Backend\Block\Widget\Grid\Extended
25+
class Product extends Extended
2226
{
2327
/**
24-
* Core registry
25-
*
26-
* @var \Magento\Framework\Registry
28+
* @var Registry
2729
*/
2830
protected $_coreRegistry = null;
2931

3032
/**
31-
* @var \Magento\Catalog\Model\ProductFactory
33+
* @var ProductFactory
3234
*/
3335
protected $_productFactory;
3436

@@ -43,19 +45,19 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended
4345
private $visibility;
4446

4547
/**
46-
* @param \Magento\Backend\Block\Template\Context $context
47-
* @param \Magento\Backend\Helper\Data $backendHelper
48-
* @param \Magento\Catalog\Model\ProductFactory $productFactory
49-
* @param \Magento\Framework\Registry $coreRegistry
48+
* @param Context $context
49+
* @param Data $backendHelper
50+
* @param ProductFactory $productFactory
51+
* @param Registry $coreRegistry
5052
* @param array $data
5153
* @param Visibility|null $visibility
5254
* @param Status|null $status
5355
*/
5456
public function __construct(
55-
\Magento\Backend\Block\Template\Context $context,
56-
\Magento\Backend\Helper\Data $backendHelper,
57-
\Magento\Catalog\Model\ProductFactory $productFactory,
58-
\Magento\Framework\Registry $coreRegistry,
57+
Context $context,
58+
Data $backendHelper,
59+
ProductFactory $productFactory,
60+
Registry $coreRegistry,
5961
array $data = [],
6062
Visibility $visibility = null,
6163
Status $status = null
@@ -68,6 +70,8 @@ public function __construct(
6870
}
6971

7072
/**
73+
* Initialize object
74+
*
7175
* @return void
7276
*/
7377
protected function _construct()
@@ -79,6 +83,8 @@ protected function _construct()
7983
}
8084

8185
/**
86+
* Get current category
87+
*
8288
* @return array|null
8389
*/
8490
public function getCategory()
@@ -87,6 +93,8 @@ public function getCategory()
8793
}
8894

8995
/**
96+
* Add column filter to collection
97+
*
9098
* @param Column $column
9199
* @return $this
92100
*/
@@ -110,6 +118,8 @@ protected function _addColumnFilterToCollection($column)
110118
}
111119

112120
/**
121+
* Prepare collection.
122+
*
113123
* @return Grid
114124
*/
115125
protected function _prepareCollection()
@@ -136,6 +146,7 @@ protected function _prepareCollection()
136146
'left'
137147
);
138148
$storeId = (int)$this->getRequest()->getParam('store', 0);
149+
$collection->setStoreId($storeId);
139150
if ($storeId > 0) {
140151
$collection->addStoreFilter($storeId);
141152
}
@@ -153,6 +164,8 @@ protected function _prepareCollection()
153164
}
154165

155166
/**
167+
* Prepare columns.
168+
*
156169
* @return Extended
157170
*/
158171
protected function _prepareColumns()
@@ -230,6 +243,8 @@ protected function _prepareColumns()
230243
}
231244

232245
/**
246+
* Retrieve grid reload url
247+
*
233248
* @return string
234249
*/
235250
public function getGridUrl()
@@ -238,6 +253,8 @@ public function getGridUrl()
238253
}
239254

240255
/**
256+
* Get selected products
257+
*
241258
* @return array
242259
*/
243260
protected function _getSelectedProducts()

app/code/Magento/CustomerImportExport/Model/Import/Customer.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
namespace Magento\CustomerImportExport\Model\Import;
99

1010
use Magento\Customer\Api\Data\CustomerInterface;
11-
use Magento\ImportExport\Model\Import;
12-
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
13-
use Magento\ImportExport\Model\Import\AbstractSource;
1411
use Magento\Customer\Model\Indexer\Processor;
1512
use Magento\Framework\App\ObjectManager;
13+
use Magento\ImportExport\Model\Import;
14+
use Magento\ImportExport\Model\Import\AbstractSource;
15+
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
1616

1717
/**
1818
* Customer entity import
@@ -162,6 +162,7 @@ class Customer extends AbstractCustomer
162162
'failures_num',
163163
'first_failure',
164164
'lock_expires',
165+
CustomerInterface::DISABLE_AUTO_GROUP_CHANGE,
165166
];
166167

167168
/**
@@ -413,7 +414,6 @@ protected function _prepareDataForUpdate(array $rowData)
413414
} else {
414415
$createdAt = (new \DateTime())->setTimestamp(strtotime($rowData['created_at']));
415416
}
416-
417417
$emailInLowercase = strtolower(trim($rowData[self::COLUMN_EMAIL]));
418418
$newCustomer = false;
419419
$entityId = $this->_getCustomerId($emailInLowercase, $rowData[self::COLUMN_WEBSITE]);
@@ -448,7 +448,6 @@ protected function _prepareDataForUpdate(array $rowData)
448448
$value = (new \DateTime())->setTimestamp(strtotime($value));
449449
$value = $value->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
450450
}
451-
452451
if (!$this->_attributes[$attributeCode]['is_static']) {
453452
/** @var $attribute \Magento\Customer\Model\Attribute */
454453
$attribute = $this->_customerModel->getAttribute($attributeCode);
@@ -488,9 +487,12 @@ protected function _prepareDataForUpdate(array $rowData)
488487
} else {
489488
$entityRow['store_id'] = $this->getCustomerStoreId($emailInLowercase, $rowData[self::COLUMN_WEBSITE]);
490489
}
490+
if (!empty($rowData[CustomerInterface::DISABLE_AUTO_GROUP_CHANGE])) {
491+
$entityRow[CustomerInterface::DISABLE_AUTO_GROUP_CHANGE] =
492+
$rowData[CustomerInterface::DISABLE_AUTO_GROUP_CHANGE];
493+
}
491494
$entitiesToUpdate[] = $entityRow;
492495
}
493-
494496
return [
495497
self::ENTITIES_TO_CREATE_KEY => $entitiesToCreate,
496498
self::ENTITIES_TO_UPDATE_KEY => $entitiesToUpdate,

app/code/Magento/Sales/Model/Order/Creditmemo.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,10 @@ public function isLast()
563563
{
564564
$items = $this->getAllItems();
565565
foreach ($items as $item) {
566+
if ($item->getOrderItem()->isDummy()) {
567+
continue;
568+
}
569+
566570
if (!$item->isLast()) {
567571
return false;
568572
}

app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Sales\Model\Order\Creditmemo\CommentFactory;
2121
use Magento\Sales\Model\Order\Creditmemo\Config;
2222
use Magento\Sales\Model\Order\Creditmemo\Item;
23+
use Magento\Sales\Model\Order\Item as OrderItem;
2324
use Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item\Collection as ItemCollection;
2425
use Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item\CollectionFactory;
2526
use Magento\Store\Model\StoreManagerInterface;
@@ -201,4 +202,40 @@ public function testGetItemsCollectionWithoutId()
201202
$itemsCollection = $this->creditmemo->getItemsCollection();
202203
$this->assertEquals($items, $itemsCollection);
203204
}
205+
206+
public function testIsLastForLastCreditMemo(): void
207+
{
208+
$item = $this->getMockBuilder(Item::class)->disableOriginalConstructor()->getMock();
209+
$orderItem = $this->getMockBuilder(OrderItem::class)->disableOriginalConstructor()->getMock();
210+
$orderItem
211+
->expects($this->once())
212+
->method('isDummy')
213+
->willReturn(true);
214+
$item->expects($this->once())
215+
->method('getOrderItem')
216+
->willReturn($orderItem);
217+
$this->creditmemo->setItems([$item]);
218+
$this->assertTrue($this->creditmemo->isLast());
219+
}
220+
221+
public function testIsLastForNonLastCreditMemo(): void
222+
{
223+
$item = $this->getMockBuilder(Item::class)->disableOriginalConstructor()->getMock();
224+
$orderItem = $this->getMockBuilder(OrderItem::class)->disableOriginalConstructor()->getMock();
225+
$orderItem
226+
->expects($this->once())
227+
->method('isDummy')
228+
->willReturn(false);
229+
$item->expects($this->once())
230+
->method('getOrderItem')
231+
->willReturn($orderItem);
232+
$item->expects($this->once())
233+
->method('getOrderItem')
234+
->willReturn($orderItem);
235+
$item->expects($this->once())
236+
->method('isLast')
237+
->willReturn(false);
238+
$this->creditmemo->setItems([$item]);
239+
$this->assertFalse($this->creditmemo->isLast());
240+
}
204241
}

0 commit comments

Comments
 (0)