Skip to content

Commit 90ba10f

Browse files
committed
Merge branch 'develop' of github.corp.magento.com:magento2/magento2ce into MAGETWO-51942
2 parents 9daba8c + e04ef1b commit 90ba10f

File tree

42 files changed

+575
-251
lines changed

Some content is hidden

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

42 files changed

+575
-251
lines changed

app/code/Magento/Checkout/Model/Cart.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/**
1515
* Shopping cart model
1616
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17+
* @deprecated
1718
*/
1819
class Cart extends DataObject implements CartInterface
1920
{

app/code/Magento/Checkout/Model/Cart/CartInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Shopping cart interface
1212
*
1313
* @author Magento Core Team <core@magentocommerce.com>
14+
* @deprecated
1415
*/
1516
interface CartInterface
1617
{

app/code/Magento/Checkout/Model/Sidebar.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use Magento\Quote\Api\Data\CartItemInterface;
1313
use Magento\Quote\Model\Quote\Address\Total;
1414

15+
/**
16+
* @deprecated
17+
*/
1518
class Sidebar
1619
{
1720
/**

app/code/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Downloadable.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function afterInitialize(
7777
if (!$linkData || (isset($linkData['is_delete']) && (bool)$linkData['is_delete'])) {
7878
continue;
7979
} else {
80-
unset($linkData['link_id']);
80+
//unset($linkData['link_id']);
8181
// TODO: need to implement setLinkFileContent()
8282
$link = $this->linkFactory->create(['data' => $linkData]);
8383
if (isset($linkData['type'])) {
@@ -89,7 +89,9 @@ public function afterInitialize(
8989
if (isset($linkData['file_content'])) {
9090
$link->setLinkFileContent($linkData['file_content']);
9191
}
92-
$link->setId(null);
92+
if (isset($linkData['link_id'])) {
93+
$link->setId($linkData['link_id']);
94+
}
9395
if (isset($linkData['sample']['type'])) {
9496
$link->setSampleType($linkData['sample']['type']);
9597
}
@@ -125,10 +127,11 @@ public function afterInitialize(
125127
if (!$sampleData || (isset($sampleData['is_delete']) && (bool)$sampleData['is_delete'])) {
126128
continue;
127129
} else {
128-
unset($sampleData['sample_id']);
129130
$sample = $this->sampleFactory->create(['data' => $sampleData]);
130-
$sample->setId(null);
131131
$sample->setStoreId($product->getStoreId());
132+
if (isset($sampleData['sample_id'])) {
133+
$sample->setId($sampleData['sample_id']);
134+
}
132135
if (isset($sampleData['type'])) {
133136
$sample->setSampleType($sampleData['type']);
134137
}

app/code/Magento/Downloadable/Model/Link/SaveHandler.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,26 @@ public function __construct(LinkRepository $linkRepository)
3636
*/
3737
public function execute($entityType, $entity, $arguments = [])
3838
{
39+
/** @var \Magento\Catalog\Api\Data\ProductInterface $entity */
3940
if ($entity->getTypeId() !== 'downloadable') {
4041
return $entity;
4142
}
42-
/** @var \Magento\Catalog\Api\Data\ProductInterface $entity */
43-
foreach ($this->linkRepository->getList($entity->getSku()) as $link) {
44-
$this->linkRepository->delete($link->getId());
45-
}
43+
44+
$oldLinks = $this->linkRepository->getList($entity->getSku());
4645
$links = $entity->getExtensionAttributes()->getDownloadableProductLinks() ?: [];
46+
$updatedLinkIds = [];
4747
foreach ($links as $link) {
48+
if ($link->getId()) {
49+
$updatedLinkIds[] = $link->getId();
50+
}
4851
$this->linkRepository->save($entity->getSku(), $link, !(bool)$entity->getStoreId());
4952
}
53+
foreach ($oldLinks as $link) {
54+
if (!in_array($link->getId(), $updatedLinkIds)) {
55+
$this->linkRepository->delete($link->getId());
56+
}
57+
}
58+
5059
return $entity;
5160
}
5261
}

app/code/Magento/Downloadable/Model/Sample/SaveHandler.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,22 @@ public function execute($entityType, $entity, $arguments = [])
3939
if ($entity->getTypeId() != \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
4040
return $entity;
4141
}
42-
/** @var \Magento\Catalog\Api\Data\ProductInterface $entity */
43-
foreach ($this->sampleRepository->getList($entity->getSku()) as $sample) {
44-
$this->sampleRepository->delete($sample->getId());
45-
}
42+
43+
$oldSamples = $this->sampleRepository->getList($entity->getSku());
4644
$samples = $entity->getExtensionAttributes()->getDownloadableProductSamples() ?: [];
45+
$updatedSampleIds = [];
4746
foreach ($samples as $sample) {
47+
if ($sample->getId()) {
48+
$updatedSampleIds[] = $sample->getId();
49+
}
4850
$this->sampleRepository->save($entity->getSku(), $sample, !(bool)$entity->getStoreId());
4951
}
52+
foreach ($oldSamples as $sample) {
53+
if (!in_array($sample->getId(), $updatedSampleIds)) {
54+
$this->sampleRepository->delete($sample->getId());
55+
}
56+
}
57+
5058
return $entity;
5159
}
5260
}

app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,15 @@ public function getAssociatedProducts($product)
219219
return $product->getData($this->_keyAssociatedProducts);
220220
}
221221

222+
/**
223+
* @param \Magento\Catalog\Model\Product $product
224+
* @return \Magento\Catalog\Model\Product
225+
*/
226+
public function flushAssociatedProductsCache($product)
227+
{
228+
return $product->unsData($this->_keyAssociatedProducts);
229+
}
230+
222231
/**
223232
* Add status filter to collection
224233
*

app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/GroupedTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ public function testPrepareForCartAdvancedEmpty()
375375
$this->_model->prepareForCartAdvanced($buyRequest, $this->product)
376376
);
377377

378-
379378
$buyRequest->setSuperGroup(1);
380379
$this->assertEquals(
381380
$expectedMsg,
@@ -603,4 +602,14 @@ public function testPrepareForCartAdvancedZeroQty()
603602
->will($this->returnValue([$associatedProduct]));
604603
$this->assertEquals($expectedMsg, $this->_model->prepareForCartAdvanced($buyRequest, $this->product));
605604
}
605+
606+
public function testFlushAssociatedProductsCache()
607+
{
608+
$productMock = $this->getMock('\Magento\Catalog\Model\Product', ['unsData'], [], '', false);
609+
$productMock->expects($this->once())
610+
->method('unsData')
611+
->with('_cache_instance_associated_products')
612+
->willReturnSelf();
613+
$this->assertEquals($productMock, $this->_model->flushAssociatedProductsCache($productMock));
614+
}
606615
}

app/code/Magento/Payment/Model/Method/Cc.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ public function validate()
144144
'|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}' .
145145
'|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}' .
146146
'|5[0-9]{14}))$/',
147+
'MI' => '/^(5(0|[6-9])|63|67(?!59|6770|6774))\d*$/',
148+
'MD' => '/^(6759(?!24|38|40|6[3-9]|70|76)|676770|676774)\d*$/',
147149
];
148150

149151
$ccNumAndTypeMatches = isset(
@@ -213,6 +215,8 @@ public function getVerificationRegEx()
213215
'SO' => '/^[0-9]{3,4}$/',
214216
'OT' => '/^[0-9]{3,4}$/',
215217
'JCB' => '/^[0-9]{3,4}$/',
218+
'MI' => '/^[0-9]{3}$/',
219+
'MD' => '/^[0-9]{3}$/',
216220
];
217221
return $verificationExpList;
218222
}

app/code/Magento/Paypal/Model/Report/Settlement.php

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Magento\Paypal\Model\Report;
1010

11+
use DateTime;
1112
use Magento\Framework\Filesystem;
1213
use Magento\Framework\Filesystem\DirectoryList;
1314

@@ -162,6 +163,13 @@ class Settlement extends \Magento\Framework\Model\AbstractModel
162163
*/
163164
protected $_scopeConfig;
164165

166+
/**
167+
* Columns with DateTime data type
168+
*
169+
* @var array
170+
*/
171+
private $dateTimeColumns = ['transaction_initiation_date', 'transaction_completion_date'];
172+
165173
/**
166174
* @param \Magento\Framework\Model\Context $context
167175
* @param \Magento\Framework\Registry $registry
@@ -249,7 +257,8 @@ public function fetchAndSave(\Magento\Framework\Filesystem\Io\Sftp $connection)
249257

250258
// Set last modified date, this value will be overwritten during parsing
251259
if (isset($attributes['mtime'])) {
252-
$lastModified = new \DateTime($attributes['mtime']);
260+
$date = new \DateTime();
261+
$lastModified = $date->setTimestamp($attributes['mtime']);
253262
$this->setReportLastModified(
254263
$lastModified->format('Y-m-d H:i:s')
255264
);
@@ -324,7 +333,7 @@ public function parseCsv($localCsv, $format = 'new')
324333
$rowMap = $this->_csvColumns[$format]['rowmap'];
325334

326335
$flippedSectionColumns = array_flip($sectionColumns);
327-
$stream = $this->_tmpDirectory->openFile($localCsv);
336+
$stream = $this->_tmpDirectory->openFile($localCsv, 'r');
328337
while ($line = $stream->readCsv()) {
329338
if (empty($line)) {
330339
// The line was empty, so skip it.
@@ -360,11 +369,7 @@ public function parseCsv($localCsv, $format = 'new')
360369
break;
361370
case 'SB':
362371
// Section body.
363-
$bodyItem = [];
364-
for ($i = 1; $i < count($line); $i++) {
365-
$bodyItem[$rowMap[$flippedSectionColumns[$i]]] = $line[$i];
366-
}
367-
$this->_rows[] = $bodyItem;
372+
$this->_rows[] = $this->getBodyItems($line, $flippedSectionColumns, $rowMap);
368373
break;
369374
case 'SC':
370375
// Section records count.
@@ -385,6 +390,41 @@ public function parseCsv($localCsv, $format = 'new')
385390
return $this;
386391
}
387392

393+
/**
394+
* Parse columns from line of csv file
395+
*
396+
* @param array $line
397+
* @param array $sectionColumns
398+
* @param array $rowMap
399+
* @return array
400+
*/
401+
private function getBodyItems(array $line, array $sectionColumns, array $rowMap)
402+
{
403+
$bodyItem = [];
404+
for ($i = 1, $count = count($line); $i < $count; $i++) {
405+
if(isset($rowMap[$sectionColumns[$i]])) {
406+
if (in_array($rowMap[$sectionColumns[$i]], $this->dateTimeColumns)) {
407+
$line[$i] = $this->formatDateTimeColumns($line[$i]);
408+
}
409+
$bodyItem[$rowMap[$sectionColumns[$i]]] = $line[$i];
410+
}
411+
}
412+
return $bodyItem;
413+
}
414+
415+
/**
416+
* Format date columns in UTC
417+
*
418+
* @param string $lineItem
419+
* @return string
420+
*/
421+
private function formatDateTimeColumns($lineItem)
422+
{
423+
/** @var DateTime $date */
424+
$date = new DateTime($lineItem, new \DateTimeZone('UTC'));
425+
return $date->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
426+
}
427+
388428
/**
389429
* Load report by unique key (accoutn + report date)
390430
*

0 commit comments

Comments
 (0)