Skip to content

Commit 74f9337

Browse files
author
Momotenko,Natalia(nmomotenko)
committed
Merge pull request #81 from magento-firedrakes/MAGETWO-44741
[Firedrakes] Bugfixes
2 parents 820f306 + 7c2c298 commit 74f9337

File tree

47 files changed

+656
-221
lines changed

Some content is hidden

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

47 files changed

+656
-221
lines changed

app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,16 @@ protected function cleanByIds($productIds)
213213
{
214214
$this->connection->deleteFromSelect(
215215
$this->connection
216-
->select($this->resource->getTableName('catalogrule_product'), 'product_id')
216+
->select()
217+
->from($this->resource->getTableName('catalogrule_product'), 'product_id')
217218
->distinct()
218219
->where('product_id IN (?)', $productIds),
219220
$this->resource->getTableName('catalogrule_product')
220221
);
221222

222223
$this->connection->deleteFromSelect(
223-
$this->connection->select($this->resource->getTableName('catalogrule_product_price'), 'product_id')
224+
$this->connection->select()
225+
->from($this->resource->getTableName('catalogrule_product_price'), 'product_id')
224226
->distinct()
225227
->where('product_id IN (?)', $productIds),
226228
$this->resource->getTableName('catalogrule_product_price')
@@ -240,6 +242,10 @@ protected function applyRule(Rule $rule, $product)
240242
$productId = $product->getId();
241243
$websiteIds = array_intersect($product->getWebsiteIds(), $rule->getWebsiteIds());
242244

245+
if (!$rule->validate($product)) {
246+
return $this;
247+
}
248+
243249
$this->connection->delete(
244250
$this->resource->getTableName('catalogrule_product'),
245251
[
@@ -248,14 +254,6 @@ protected function applyRule(Rule $rule, $product)
248254
]
249255
);
250256

251-
if (!$rule->validate($product)) {
252-
$this->connection->delete(
253-
$this->resource->getTableName('catalogrule_product_price'),
254-
[$this->connection->quoteInto('product_id = ?', $productId)]
255-
);
256-
return $this;
257-
}
258-
259257
$customerGroupIds = $rule->getCustomerGroupIds();
260258
$fromTime = strtotime($rule->getFromDate());
261259
$toTime = strtotime($rule->getToDate());

app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@
267267
</item>
268268
</argument>
269269
</column>
270-
<column name="creation_time">
270+
<column name="creation_time" class="Magento\Ui\Component\Listing\Columns\Date">
271271
<argument name="data" xsi:type="array">
272272
<item name="config" xsi:type="array">
273273
<item name="filter" xsi:type="string">dateRange</item>
@@ -277,7 +277,7 @@
277277
</item>
278278
</argument>
279279
</column>
280-
<column name="update_time">
280+
<column name="update_time" class="Magento\Ui\Component\Listing\Columns\Date">
281281
<argument name="data" xsi:type="array">
282282
<item name="config" xsi:type="array">
283283
<item name="filter" xsi:type="string">dateRange</item>

app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@
293293
</item>
294294
</argument>
295295
</column>
296-
<column name="creation_time">
296+
<column name="creation_time" class="Magento\Ui\Component\Listing\Columns\Date">
297297
<argument name="data" xsi:type="array">
298298
<item name="config" xsi:type="array">
299299
<item name="filter" xsi:type="string">dateRange</item>
@@ -303,7 +303,7 @@
303303
</item>
304304
</argument>
305305
</column>
306-
<column name="update_time">
306+
<column name="update_time" class="Magento\Ui\Component\Listing\Columns\Date">
307307
<argument name="data" xsi:type="array">
308308
<item name="config" xsi:type="array">
309309
<item name="filter" xsi:type="string">dateRange</item>
@@ -313,7 +313,7 @@
313313
</item>
314314
</argument>
315315
</column>
316-
<column name="custom_theme_from">
316+
<column name="custom_theme_from" class="Magento\Ui\Component\Listing\Columns\Date">
317317
<argument name="data" xsi:type="array">
318318
<item name="config" xsi:type="array">
319319
<item name="filter" xsi:type="string">dateRange</item>
@@ -326,7 +326,7 @@
326326
</item>
327327
</argument>
328328
</column>
329-
<column name="custom_theme_to">
329+
<column name="custom_theme_to" class="Magento\Ui\Component\Listing\Columns\Date">
330330
<argument name="data" xsi:type="array">
331331
<item name="config" xsi:type="array">
332332
<item name="filter" xsi:type="string">dateRange</item>

app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function getFinalPrice($qty, $product)
2121
if ($qty === null && $product->getCalculatedFinalPrice() !== null) {
2222
return $product->getCalculatedFinalPrice();
2323
}
24-
if ($product->getCustomOption('simple_product')) {
24+
if ($product->getCustomOption('simple_product') && $product->getCustomOption('simple_product')->getProduct()) {
2525
return parent::getFinalPrice($qty, $product->getCustomOption('simple_product')->getProduct());
2626
} else {
2727
$priceInfo = $product->getPriceInfo();

app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,12 @@
310310
</item>
311311
</argument>
312312
</column>
313-
<column name="created_at">
313+
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
314314
<argument name="data" xsi:type="array">
315315
<item name="config" xsi:type="array">
316316
<item name="filter" xsi:type="string">dateRange</item>
317317
<item name="dataType" xsi:type="string">date</item>
318+
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
318319
<item name="label" xsi:type="string" translate="true">Customer Since</item>
319320
<item name="sortOrder" xsi:type="number">100</item>
320321
</item>
@@ -332,7 +333,7 @@
332333
</item>
333334
</argument>
334335
</column>
335-
<column name="last_visit_at">
336+
<column name="last_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
336337
<argument name="data" xsi:type="array">
337338
<item name="config" xsi:type="array">
338339
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
@@ -380,7 +381,7 @@
380381
</item>
381382
</argument>
382383
</column>
383-
<column name="dob">
384+
<column name="dob" class="Magento\Ui\Component\Listing\Columns\Date">
384385
<argument name="data" xsi:type="array">
385386
<item name="config" xsi:type="array">
386387
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>

app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,22 @@
142142
</item>
143143
</argument>
144144
</column> -->
145-
<column name="first_visit_at">
145+
<column name="first_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
146146
<argument name="data" xsi:type="array">
147147
<item name="config" xsi:type="array">
148+
<item name="filter" xsi:type="string">dateRange</item>
148149
<item name="dataType" xsi:type="string">date</item>
150+
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
149151
<item name="label" xsi:type="string" translate="true">Session Start Time</item>
150152
</item>
151153
</argument>
152154
</column>
153-
<column name="last_visit_at">
155+
<column name="last_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
154156
<argument name="data" xsi:type="array">
155157
<item name="config" xsi:type="array">
156158
<item name="filter" xsi:type="string">dateRange</item>
157159
<item name="dataType" xsi:type="string">date</item>
160+
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
158161
<item name="label" xsi:type="string" translate="true">Last Activity</item>
159162
</item>
160163
</argument>

app/code/Magento/OfflinePayments/view/adminhtml/templates/form/purchaseorder.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<div class="admin__field-control">
1616
<input type="text" id="po_number" name="payment[po_number]"
1717
title="<?php echo $block->escapeHtml(__("Purchase Order Number")) ?>" class="required-entry admin__control-text"
18-
value="<?php /* @noEscape */ $block->getInfoData('po_number') ?>"/>
18+
value="<?php /* @noEscape */ echo $block->getInfoData('po_number') ?>"/>
1919
</div>
2020
</div>
2121
</fieldset>

app/code/Magento/Paypal/Model/ResourceModel/Billing/Agreement.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,16 @@ public function addOrderRelation($agreementId, $orderId)
4646
public function addOrdersFilter(\Magento\Framework\Data\Collection\AbstractDb $orderCollection, $agreementIds)
4747
{
4848
$agreementIds = is_array($agreementIds) ? $agreementIds : [$agreementIds];
49-
$orderCollection->getSelect()->joinInner(
50-
['pbao' => $this->getTable('paypal_billing_agreement_order')],
51-
'main_table.entity_id = pbao.order_id',
52-
[]
53-
)->where(
54-
'pbao.agreement_id IN(?)',
55-
$agreementIds
49+
$orderIds = $this->getConnection()->fetchCol(
50+
$this->getConnection()->select()
51+
->from(['pbao' => $this->getTable('paypal_billing_agreement_order')], ['order_id'])
52+
->where(
53+
'pbao.agreement_id IN(?)',
54+
$agreementIds
55+
)
5656
);
57+
$orderCollection->getSelect()
58+
->where('main_table.entity_id IN (?)', $orderIds);
5759
return $this;
5860
}
5961
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Paypal\Test\Unit\Model\ResourceModel\Billing;
8+
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
10+
11+
/**
12+
* Class AgreementTest
13+
*/
14+
class AgreementTest extends \PHPUnit_Framework_TestCase
15+
{
16+
/**
17+
* @var \Magento\Paypal\Model\ResourceModel\Billing\Agreement
18+
*/
19+
protected $agreementResource;
20+
21+
/**
22+
* @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
23+
*/
24+
protected $connectionMock;
25+
26+
/**
27+
* @var \Magento\Framework\Data\Collection\AbstractDb|\PHPUnit_Framework_MockObject_MockObject
28+
*/
29+
protected $collectionMock;
30+
31+
/**
32+
* @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject
33+
*/
34+
protected $selectMock;
35+
36+
/**
37+
* @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
38+
*/
39+
protected $resourceConnectionMock;
40+
41+
public function setUp()
42+
{
43+
$objectManager = new ObjectManagerHelper($this);
44+
$contextMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\Context')
45+
->disableOriginalConstructor()
46+
->getMock();
47+
$this->resourceConnectionMock = $this->getMock(
48+
'Magento\Framework\App\ResourceConnection',
49+
[
50+
'getConnection',
51+
'getTableName'
52+
],
53+
[],
54+
'',
55+
false
56+
);
57+
$this->collectionMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb')
58+
->disableOriginalConstructor()
59+
->setMethods(['getSelect'])
60+
->getMockForAbstractClass();
61+
$this->connectionMock = $this->getMock(
62+
'Magento\Framework\DB\Adapter\Pdo\Mysql',
63+
[],
64+
[],
65+
'',
66+
false
67+
);
68+
$this->selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false);
69+
$contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceConnectionMock);
70+
$this->agreementResource = $objectManager->getObject(
71+
'Magento\Paypal\Model\ResourceModel\Billing\Agreement',
72+
[
73+
'context' => $contextMock,
74+
]
75+
);
76+
}
77+
78+
public function testAddOrdersFilter()
79+
{
80+
$this->resourceConnectionMock->expects($this->exactly(2))
81+
->method('getConnection')
82+
->willReturn($this->connectionMock);
83+
$this->resourceConnectionMock->expects($this->once())
84+
->method('getTableName')
85+
->with('paypal_billing_agreement_order')
86+
->willReturn('pref_paypal_billing_agreement_order');
87+
$this->connectionMock->expects($this->once())
88+
->method('select')
89+
->willReturn($this->selectMock);
90+
$this->selectMock->expects($this->once())
91+
->method('from')
92+
->with(['pbao' => 'pref_paypal_billing_agreement_order'], ['order_id'], null)
93+
->willReturnSelf();
94+
$this->selectMock->expects($this->exactly(2))
95+
->method('where')
96+
->withConsecutive(
97+
['pbao.agreement_id IN(?)', [100]],
98+
['main_table.entity_id IN (?)', [500]]
99+
)
100+
->willReturnSelf();
101+
$this->connectionMock->expects($this->once())
102+
->method('fetchCol')
103+
->with($this->selectMock, [])
104+
->willReturn([500]);
105+
$this->collectionMock->expects($this->once())
106+
->method('getSelect')
107+
->willReturn($this->selectMock);
108+
$this->assertEquals(
109+
$this->agreementResource,
110+
$this->agreementResource->addOrdersFilter($this->collectionMock, 100)
111+
);
112+
}
113+
}

app/code/Magento/Sales/Block/Order/Totals.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ protected function _initTotals()
164164
$this->_totals['base_grandtotal'] = new \Magento\Framework\DataObject(
165165
[
166166
'code' => 'base_grandtotal',
167-
'value' => $this->getOrder()->formatBasePrice($source->getBaseGrandTotal()),
167+
'value' => $this->getOrder()->formatPrice($source->getGrandTotal()),
168168
'label' => __('Grand Total to be Charged'),
169169
'is_formated' => true,
170170
]

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Order extends \Magento\Framework\DataObject
3232
protected $_invoiceItemFactory;
3333

3434
/**
35-
* @var \Magento\Sales\Model\Order\ShipmentRepository
35+
* @var \Magento\Sales\Api\ShipmentRepositoryInterface
3636
*/
3737
protected $shipmentRepository;
3838

@@ -55,7 +55,7 @@ class Order extends \Magento\Framework\DataObject
5555
* @param \Magento\Framework\Event\ManagerInterface $eventManager
5656
* @param \Magento\Sales\Api\InvoiceRepositoryInterface $invoiceRepository
5757
* @param \Magento\Sales\Model\Order\Invoice\ItemFactory $invoiceItemFactory
58-
* @param \Magento\Sales\Model\Order\ShipmentRepository $shipmentRepository
58+
* @param \Magento\Sales\Api\ShipmentRepositoryInterface $shipmentRepository
5959
* @param \Magento\Sales\Model\Order\Shipment\ItemFactory $shipmentItemFactory
6060
* @param \Magento\Sales\Api\CreditmemoRepositoryInterface $creditmemoRepository
6161
* @param \Magento\Sales\Model\Order\Creditmemo\ItemFactory $creditmemoItemFactory
@@ -68,7 +68,7 @@ public function __construct(
6868
\Magento\Framework\Event\ManagerInterface $eventManager,
6969
\Magento\Sales\Api\InvoiceRepositoryInterface $invoiceRepository,
7070
\Magento\Sales\Model\Order\Invoice\ItemFactory $invoiceItemFactory,
71-
\Magento\Sales\Model\Order\ShipmentRepository $shipmentRepository,
71+
\Magento\Sales\Api\ShipmentRepositoryInterface $shipmentRepository,
7272
\Magento\Sales\Model\Order\Shipment\ItemFactory $shipmentItemFactory,
7373
\Magento\Sales\Api\CreditmemoRepositoryInterface $creditmemoRepository,
7474
\Magento\Sales\Model\Order\Creditmemo\ItemFactory $creditmemoItemFactory,

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ public function get($id)
6262

6363
if (!isset($this->registry[$id])) {
6464
/** @var \Magento\Sales\Api\Data\OrderAddressInterface $entity */
65-
$entity = $this->metadata->getNewInstance();
66-
67-
$this->metadata->getMapper()->load($entity, $id);
68-
65+
$entity = $this->metadata->getNewInstance()->load($id);
6966
if (!$entity->getEntityId()) {
7067
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
7168
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ public function get($id)
6464
}
6565
if (!isset($this->registry[$id])) {
6666
/** @var \Magento\Sales\Api\Data\CreditmemoInterface $entity */
67-
$entity = $this->metadata->getNewInstance();
68-
$this->metadata->getMapper()->load($entity, $id);
67+
$entity = $this->metadata->getNewInstance()->load($id);
6968
if (!$entity->getEntityId()) {
7069
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
7170
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public function get($id)
6262
}
6363
if (!isset($this->registry[$id])) {
6464
/** @var \Magento\Sales\Api\Data\InvoiceInterface $entity */
65-
$entity = $this->metadata->getNewInstance();
66-
$this->metadata->getMapper()->load($entity, $id);
65+
$entity = $this->metadata->getNewInstance()->load($id);
6766
if (!$entity->getEntityId()) {
6867
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
6968
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ public function get($id)
9999
}
100100
if (!isset($this->registry[$id])) {
101101
/** @var OrderItemInterface $orderItem */
102-
$orderItem = $this->metadata->getNewInstance();
103-
$this->metadata->getMapper()->load($orderItem, $id);
102+
$orderItem = $this->metadata->getNewInstance()->load($id);
104103
if (!$orderItem->getItemId()) {
105104
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
106105
}

app/code/Magento/Sales/Model/Order/Payment/Repository.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ public function get($id)
7979
throw new \Magento\Framework\Exception\InputException(__('ID required'));
8080
}
8181
if (!isset($this->registry[$id])) {
82-
$entity = $this->metaData->getNewInstance();
83-
$this->metaData->getMapper()->load($entity, $id);
82+
$entity = $this->metaData->getNewInstance()->load($id);
8483
if (!$entity->getId()) {
8584
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
8685
}

0 commit comments

Comments
 (0)