Skip to content

Commit d1f0447

Browse files
[Magento Community Engineering] Community Contributions - 2.4-develop
- merged latest code from mainline branch
2 parents 8d893d5 + ddf3c62 commit d1f0447

File tree

4 files changed

+48
-12
lines changed

4 files changed

+48
-12
lines changed

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,19 +219,18 @@ define([
219219
_.each(tmpData, function (row, index) {
220220
path = this.dataScope + '.' + this.index + '.' + (this.startIndex + index);
221221
row.attributes = $('<i></i>').text(row.attributes).html();
222-
row.sku = row.sku;
223222
this.source.set(path, row);
224223
}, this);
225224

226225
this.source.set(this.dataScope + '.' + this.index, data);
227226
this.parsePagesData(data);
228227

229228
// Render
230-
dataCount = data.length;
229+
dataCount = tmpData.length;
231230
elemsCount = this.elems().length;
232231

233232
if (dataCount > elemsCount) {
234-
this.getChildItems().each(function (elemData, index) {
233+
tmpData.each(function (elemData, index) {
235234
this.addChild(elemData, this.startIndex + index);
236235
}, this);
237236
} else {
@@ -243,6 +242,15 @@ define([
243242
this.generateAssociatedProducts();
244243
},
245244

245+
/**
246+
* Set initial property to records data
247+
*
248+
* @returns {Object} Chainable.
249+
*/
250+
setInitialProperty: function () {
251+
return this;
252+
},
253+
246254
/**
247255
* Parsed data
248256
*

app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,13 +1126,17 @@ define([
11261126
* Update whether value differs from default value
11271127
*/
11281128
setDifferedFromDefault: function () {
1129-
var recordData = utils.copy(this.recordData());
1129+
var recordData;
11301130

1131-
Array.isArray(recordData) && recordData.forEach(function (item) {
1132-
delete item['record_id'];
1133-
});
1131+
if (this.default) {
1132+
recordData = utils.copy(this.recordData());
1133+
1134+
Array.isArray(recordData) && recordData.forEach(function (item) {
1135+
delete item['record_id'];
1136+
});
11341137

1135-
this.isDifferedFromDefault(!_.isEqual(recordData, this.default));
1138+
this.isDifferedFromDefault(!_.isEqual(recordData, this.default));
1139+
}
11361140
},
11371141

11381142
/**

dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ define([
4141
})
4242
};
4343

44-
model.getChildItems = jasmine.createSpy().and.returnValue($(''));
4544
model.source = sourceMock;
4645
model.processingUnionInsertData(mockData);
4746
expect(model.source.get).toHaveBeenCalled();
48-
expect(model.getChildItems).toHaveBeenCalled();
4947
expect(expectedData[1].sku).toBe('Conf&-sdfs');
5048
});
5149

setup/src/Magento/Setup/Model/FixtureGenerator/CustomerTemplateGenerator.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Magento\Customer\Model\AddressFactory;
1111
use Magento\Customer\Model\Customer;
1212
use Magento\Customer\Model\CustomerFactory;
13+
use Magento\Directory\Model\ResourceModel\Region\CollectionFactory as RegionCollectionFactory;
14+
use Magento\Framework\App\ObjectManager;
1315
use Magento\Store\Model\StoreManagerInterface;
1416

1517
/**
@@ -32,19 +34,29 @@ class CustomerTemplateGenerator implements TemplateEntityGeneratorInterface
3234
*/
3335
private $storeManager;
3436

37+
/**
38+
* @var RegionCollectionFactory
39+
*/
40+
private $regionsCollectionFactory;
41+
3542
/**
3643
* @param CustomerFactory $customerFactory
3744
* @param AddressFactory $addressFactory
3845
* @param StoreManagerInterface $storeManager
46+
* @param RegionCollectionFactory|null $regionsCollectionFactory
3947
*/
4048
public function __construct(
4149
CustomerFactory $customerFactory,
4250
AddressFactory $addressFactory,
43-
StoreManagerInterface $storeManager
51+
StoreManagerInterface $storeManager,
52+
RegionCollectionFactory $regionsCollectionFactory = null
4453
) {
4554
$this->customerFactory = $customerFactory;
4655
$this->addressFactory = $addressFactory;
4756
$this->storeManager = $storeManager;
57+
$this->regionsCollectionFactory = $regionsCollectionFactory ?: ObjectManager::getInstance()->get(
58+
RegionCollectionFactory::class
59+
);
4860
}
4961

5062
/**
@@ -119,7 +131,7 @@ private function getAddressTemplate($customerId)
119131
'street' => 'Green str, 67',
120132
'lastname' => 'Smith',
121133
'firstname' => 'John',
122-
'region_id' => 1,
134+
'region_id' => $this->getFirstRegionId(),
123135
'fax' => '04040404',
124136
'middlename' => '',
125137
'prefix' => '',
@@ -131,4 +143,18 @@ private function getAddressTemplate($customerId)
131143
]
132144
]);
133145
}
146+
147+
/**
148+
* Get first region id.
149+
*
150+
* @return mixed
151+
*/
152+
private function getFirstRegionId()
153+
{
154+
$regionsCollection = $this->regionsCollectionFactory->create();
155+
$regionsCollection->unshiftOrder('region_id', 'ASC');
156+
$region = $regionsCollection->getFirstItem();
157+
158+
return $region->getRegionId();
159+
}
134160
}

0 commit comments

Comments
 (0)