Skip to content

Commit

Permalink
Merge pull request #81 from magento-firedrakes/MAGETWO-44741
Browse files Browse the repository at this point in the history
[Firedrakes] Bugfixes
  • Loading branch information
Momotenko,Natalia(nmomotenko) committed Oct 31, 2015
2 parents 820f306 + 7c2c298 commit 74f9337
Show file tree
Hide file tree
Showing 47 changed files with 656 additions and 221 deletions.
18 changes: 8 additions & 10 deletions app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,16 @@ protected function cleanByIds($productIds)
{
$this->connection->deleteFromSelect(
$this->connection
->select($this->resource->getTableName('catalogrule_product'), 'product_id')
->select()
->from($this->resource->getTableName('catalogrule_product'), 'product_id')
->distinct()
->where('product_id IN (?)', $productIds),
$this->resource->getTableName('catalogrule_product')
);

$this->connection->deleteFromSelect(
$this->connection->select($this->resource->getTableName('catalogrule_product_price'), 'product_id')
$this->connection->select()
->from($this->resource->getTableName('catalogrule_product_price'), 'product_id')
->distinct()
->where('product_id IN (?)', $productIds),
$this->resource->getTableName('catalogrule_product_price')
Expand All @@ -240,6 +242,10 @@ protected function applyRule(Rule $rule, $product)
$productId = $product->getId();
$websiteIds = array_intersect($product->getWebsiteIds(), $rule->getWebsiteIds());

if (!$rule->validate($product)) {
return $this;
}

$this->connection->delete(
$this->resource->getTableName('catalogrule_product'),
[
Expand All @@ -248,14 +254,6 @@ protected function applyRule(Rule $rule, $product)
]
);

if (!$rule->validate($product)) {
$this->connection->delete(
$this->resource->getTableName('catalogrule_product_price'),
[$this->connection->quoteInto('product_id = ?', $productId)]
);
return $this;
}

$customerGroupIds = $rule->getCustomerGroupIds();
$fromTime = strtotime($rule->getFromDate());
$toTime = strtotime($rule->getToDate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
</item>
</argument>
</column>
<column name="creation_time">
<column name="creation_time" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
Expand All @@ -277,7 +277,7 @@
</item>
</argument>
</column>
<column name="update_time">
<column name="update_time" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
</item>
</argument>
</column>
<column name="creation_time">
<column name="creation_time" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
Expand All @@ -303,7 +303,7 @@
</item>
</argument>
</column>
<column name="update_time">
<column name="update_time" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
Expand All @@ -313,7 +313,7 @@
</item>
</argument>
</column>
<column name="custom_theme_from">
<column name="custom_theme_from" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
Expand All @@ -326,7 +326,7 @@
</item>
</argument>
</column>
<column name="custom_theme_to">
<column name="custom_theme_to" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function getFinalPrice($qty, $product)
if ($qty === null && $product->getCalculatedFinalPrice() !== null) {
return $product->getCalculatedFinalPrice();
}
if ($product->getCustomOption('simple_product')) {
if ($product->getCustomOption('simple_product') && $product->getCustomOption('simple_product')->getProduct()) {
return parent::getFinalPrice($qty, $product->getCustomOption('simple_product')->getProduct());
} else {
$priceInfo = $product->getPriceInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,12 @@
</item>
</argument>
</column>
<column name="created_at">
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
<item name="dataType" xsi:type="string">date</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
<item name="label" xsi:type="string" translate="true">Customer Since</item>
<item name="sortOrder" xsi:type="number">100</item>
</item>
Expand All @@ -332,7 +333,7 @@
</item>
</argument>
</column>
<column name="last_visit_at">
<column name="last_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
Expand Down Expand Up @@ -380,7 +381,7 @@
</item>
</argument>
</column>
<column name="dob">
<column name="dob" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,22 @@
</item>
</argument>
</column> -->
<column name="first_visit_at">
<column name="first_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
<item name="dataType" xsi:type="string">date</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
<item name="label" xsi:type="string" translate="true">Session Start Time</item>
</item>
</argument>
</column>
<column name="last_visit_at">
<column name="last_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
<item name="dataType" xsi:type="string">date</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
<item name="label" xsi:type="string" translate="true">Last Activity</item>
</item>
</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="admin__field-control">
<input type="text" id="po_number" name="payment[po_number]"
title="<?php echo $block->escapeHtml(__("Purchase Order Number")) ?>" class="required-entry admin__control-text"
value="<?php /* @noEscape */ $block->getInfoData('po_number') ?>"/>
value="<?php /* @noEscape */ echo $block->getInfoData('po_number') ?>"/>
</div>
</div>
</fieldset>
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ public function addOrderRelation($agreementId, $orderId)
public function addOrdersFilter(\Magento\Framework\Data\Collection\AbstractDb $orderCollection, $agreementIds)
{
$agreementIds = is_array($agreementIds) ? $agreementIds : [$agreementIds];
$orderCollection->getSelect()->joinInner(
['pbao' => $this->getTable('paypal_billing_agreement_order')],
'main_table.entity_id = pbao.order_id',
[]
)->where(
'pbao.agreement_id IN(?)',
$agreementIds
$orderIds = $this->getConnection()->fetchCol(
$this->getConnection()->select()
->from(['pbao' => $this->getTable('paypal_billing_agreement_order')], ['order_id'])
->where(
'pbao.agreement_id IN(?)',
$agreementIds
)
);
$orderCollection->getSelect()
->where('main_table.entity_id IN (?)', $orderIds);
return $this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Paypal\Test\Unit\Model\ResourceModel\Billing;

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

/**
* Class AgreementTest
*/
class AgreementTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\Paypal\Model\ResourceModel\Billing\Agreement
*/
protected $agreementResource;

/**
* @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $connectionMock;

/**
* @var \Magento\Framework\Data\Collection\AbstractDb|\PHPUnit_Framework_MockObject_MockObject
*/
protected $collectionMock;

/**
* @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject
*/
protected $selectMock;

/**
* @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
*/
protected $resourceConnectionMock;

public function setUp()
{
$objectManager = new ObjectManagerHelper($this);
$contextMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\Context')
->disableOriginalConstructor()
->getMock();
$this->resourceConnectionMock = $this->getMock(
'Magento\Framework\App\ResourceConnection',
[
'getConnection',
'getTableName'
],
[],
'',
false
);
$this->collectionMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb')
->disableOriginalConstructor()
->setMethods(['getSelect'])
->getMockForAbstractClass();
$this->connectionMock = $this->getMock(
'Magento\Framework\DB\Adapter\Pdo\Mysql',
[],
[],
'',
false
);
$this->selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false);
$contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceConnectionMock);
$this->agreementResource = $objectManager->getObject(
'Magento\Paypal\Model\ResourceModel\Billing\Agreement',
[
'context' => $contextMock,
]
);
}

public function testAddOrdersFilter()
{
$this->resourceConnectionMock->expects($this->exactly(2))
->method('getConnection')
->willReturn($this->connectionMock);
$this->resourceConnectionMock->expects($this->once())
->method('getTableName')
->with('paypal_billing_agreement_order')
->willReturn('pref_paypal_billing_agreement_order');
$this->connectionMock->expects($this->once())
->method('select')
->willReturn($this->selectMock);
$this->selectMock->expects($this->once())
->method('from')
->with(['pbao' => 'pref_paypal_billing_agreement_order'], ['order_id'], null)
->willReturnSelf();
$this->selectMock->expects($this->exactly(2))
->method('where')
->withConsecutive(
['pbao.agreement_id IN(?)', [100]],
['main_table.entity_id IN (?)', [500]]
)
->willReturnSelf();
$this->connectionMock->expects($this->once())
->method('fetchCol')
->with($this->selectMock, [])
->willReturn([500]);
$this->collectionMock->expects($this->once())
->method('getSelect')
->willReturn($this->selectMock);
$this->assertEquals(
$this->agreementResource,
$this->agreementResource->addOrdersFilter($this->collectionMock, 100)
);
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Sales/Block/Order/Totals.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected function _initTotals()
$this->_totals['base_grandtotal'] = new \Magento\Framework\DataObject(
[
'code' => 'base_grandtotal',
'value' => $this->getOrder()->formatBasePrice($source->getBaseGrandTotal()),
'value' => $this->getOrder()->formatPrice($source->getGrandTotal()),
'label' => __('Grand Total to be Charged'),
'is_formated' => true,
]
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Sales/Model/Convert/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Order extends \Magento\Framework\DataObject
protected $_invoiceItemFactory;

/**
* @var \Magento\Sales\Model\Order\ShipmentRepository
* @var \Magento\Sales\Api\ShipmentRepositoryInterface
*/
protected $shipmentRepository;

Expand All @@ -55,7 +55,7 @@ class Order extends \Magento\Framework\DataObject
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Sales\Api\InvoiceRepositoryInterface $invoiceRepository
* @param \Magento\Sales\Model\Order\Invoice\ItemFactory $invoiceItemFactory
* @param \Magento\Sales\Model\Order\ShipmentRepository $shipmentRepository
* @param \Magento\Sales\Api\ShipmentRepositoryInterface $shipmentRepository
* @param \Magento\Sales\Model\Order\Shipment\ItemFactory $shipmentItemFactory
* @param \Magento\Sales\Api\CreditmemoRepositoryInterface $creditmemoRepository
* @param \Magento\Sales\Model\Order\Creditmemo\ItemFactory $creditmemoItemFactory
Expand All @@ -68,7 +68,7 @@ public function __construct(
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Sales\Api\InvoiceRepositoryInterface $invoiceRepository,
\Magento\Sales\Model\Order\Invoice\ItemFactory $invoiceItemFactory,
\Magento\Sales\Model\Order\ShipmentRepository $shipmentRepository,
\Magento\Sales\Api\ShipmentRepositoryInterface $shipmentRepository,
\Magento\Sales\Model\Order\Shipment\ItemFactory $shipmentItemFactory,
\Magento\Sales\Api\CreditmemoRepositoryInterface $creditmemoRepository,
\Magento\Sales\Model\Order\Creditmemo\ItemFactory $creditmemoItemFactory,
Expand Down
5 changes: 1 addition & 4 deletions app/code/Magento/Sales/Model/Order/AddressRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ public function get($id)

if (!isset($this->registry[$id])) {
/** @var \Magento\Sales\Api\Data\OrderAddressInterface $entity */
$entity = $this->metadata->getNewInstance();

$this->metadata->getMapper()->load($entity, $id);

$entity = $this->metadata->getNewInstance()->load($id);
if (!$entity->getEntityId()) {
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
}
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Sales/Model/Order/CreditmemoRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public function get($id)
}
if (!isset($this->registry[$id])) {
/** @var \Magento\Sales\Api\Data\CreditmemoInterface $entity */
$entity = $this->metadata->getNewInstance();
$this->metadata->getMapper()->load($entity, $id);
$entity = $this->metadata->getNewInstance()->load($id);
if (!$entity->getEntityId()) {
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
}
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Sales/Model/Order/InvoiceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public function get($id)
}
if (!isset($this->registry[$id])) {
/** @var \Magento\Sales\Api\Data\InvoiceInterface $entity */
$entity = $this->metadata->getNewInstance();
$this->metadata->getMapper()->load($entity, $id);
$entity = $this->metadata->getNewInstance()->load($id);
if (!$entity->getEntityId()) {
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
}
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Sales/Model/Order/ItemRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ public function get($id)
}
if (!isset($this->registry[$id])) {
/** @var OrderItemInterface $orderItem */
$orderItem = $this->metadata->getNewInstance();
$this->metadata->getMapper()->load($orderItem, $id);
$orderItem = $this->metadata->getNewInstance()->load($id);
if (!$orderItem->getItemId()) {
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
}
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Sales/Model/Order/Payment/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ public function get($id)
throw new \Magento\Framework\Exception\InputException(__('ID required'));
}
if (!isset($this->registry[$id])) {
$entity = $this->metaData->getNewInstance();
$this->metaData->getMapper()->load($entity, $id);
$entity = $this->metaData->getNewInstance()->load($id);
if (!$entity->getId()) {
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
}
Expand Down
Loading

0 comments on commit 74f9337

Please sign in to comment.