Skip to content

Commit

Permalink
Merge pull request #496 from magento-api/for-pr
Browse files Browse the repository at this point in the history
[API] Bug Fixes
  • Loading branch information
Paliarush, Alexander(apaliarush) committed Apr 1, 2016
2 parents 0b62520 + 6817cf4 commit d447fa6
Show file tree
Hide file tree
Showing 24 changed files with 313 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public function prepareDataSource(array $dataSource)
foreach ($dataSource['data']['items'] as & $item) {
$websites = [];
foreach ($item[$fieldName] as $websiteId) {
if (!isset($websiteNames[$websiteId])) {
continue;
}
$websites[] = $websiteNames[$websiteId];
}
$item[$fieldName] = implode(', ', $websites);
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Config/Model/Config/Backend/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ class Cache extends \Magento\Framework\App\Config\Value
/**
* Clean cache, value was changed
*
* @return void
* @return $this
*/
public function afterSave()
{
if ($this->isValueChanged()) {
$this->_cacheManager->clean($this->_cacheTags);
}
return $this;
}
}
3 changes: 2 additions & 1 deletion app/code/Magento/Config/Model/Config/Backend/Datashare.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
class Datashare extends \Magento\Framework\App\Config\Value
{
/**
* @return void
* @return $this
*/
public function afterSave()
{
return $this;
}
}
36 changes: 36 additions & 0 deletions app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Customer\Model\ResourceModel\Grid;

use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Psr\Log\LoggerInterface as Logger;

class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
{
/**
* Initialize dependencies.
*
* @param EntityFactory $entityFactory
* @param Logger $logger
* @param FetchStrategy $fetchStrategy
* @param EventManager $eventManager
* @param string $mainTable
* @param string $resourceModel
*/
public function __construct(
EntityFactory $entityFactory,
Logger $logger,
FetchStrategy $fetchStrategy,
EventManager $eventManager,
$mainTable = 'customer_grid_flat',
$resourceModel = '\Magento\Customer\Model\ResourceModel\Customer'
) {
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
}
}
6 changes: 0 additions & 6 deletions app/code/Magento/Customer/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,6 @@
<argument name="entitySnapshot" xsi:type="object">EavVersionControlSnapshot</argument>
</arguments>
</type>
<virtualType name="Magento\Customer\Model\ResourceModel\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">customer_grid_flat</argument>
<argument name="resourceModel" xsi:type="string">Magento\Customer\Model\ResourceModel\Customer</argument>
</arguments>
</virtualType>
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Directory/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<resource>Magento_Backend::currency</resource>
<group id="options" translate="label" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Currency Options</label>
<field id="base" translate="label comment" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="base" translate="label comment" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Base Currency</label>
<frontend_model>Magento\Directory\Block\Adminhtml\Frontend\Currency\Base</frontend_model>
<source_model>Magento\Config\Model\Config\Source\Locale\Currency</source_model>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,16 @@ public function execute()
$this->_setActivationInProcessMsg($isReauthorize, $integration->getName());
$this->_view->renderLayout();
$popupContent = $this->_response->getBody();
$consumer = $this->_oauthService->loadConsumer($integration->getConsumerId());
if (!$consumer->getId()) {
throw new \Magento\Framework\Oauth\Exception(
__('A consumer with ID %1 does not exist', $integration->getConsumerId())
);
}
/** Initialize response body */
$result = [
IntegrationModel::IDENTITY_LINK_URL => $integration->getIdentityLinkUrl(),
IntegrationModel::CONSUMER_ID => $integration->getConsumerId(),
'oauth_consumer_key' => $consumer->getKey(),
'popup_content' => $popupContent,
];
$this->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Integration/Model/OauthService.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function loadConsumerByKey($key)
public function postToConsumer($consumerId, $endpointUrl)
{
try {
$consumer = $this->_consumerFactory->create()->load($consumerId);
$consumer = $this->loadConsumer($consumerId);
if (!$consumer->getId()) {
throw new \Magento\Framework\Oauth\Exception(
__('A consumer with ID %1 does not exist', $consumerId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ protected function _construct()
public function _afterDelete(\Magento\Framework\Model\AbstractModel $object)
{
$connection = $this->getConnection();
$connection->delete($this->getTable('oauth_nonce'), ['consumer_id' => $object->getId()]);
$connection->delete($this->getTable('oauth_token'), ['consumer_id' => $object->getId()]);
$connection->delete($this->getTable('oauth_nonce'), ['consumer_id = ?' => (int)$object->getId()]);
$connection->delete($this->getTable('oauth_token'), ['consumer_id = ?' => (int)$object->getId()]);
return parent::_afterDelete($object);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public function testTokensExchangeReauthorize()

$this->_oauthSvcMock->expects($this->once())->method('deleteIntegrationToken');
$this->_oauthSvcMock->expects($this->once())->method('postToConsumer');
$consumerMock = $this->getMock(\Magento\Integration\Model\Oauth\Consumer::class, [], [], '' , false);
$consumerMock->expects($this->once())->method('getId')->willReturn(1);
$this->_oauthSvcMock->expects($this->once())->method('loadConsumer')->willReturn($consumerMock);

$this->_messageManager->expects($this->once())->method('addNotice');
$this->_messageManager->expects($this->never())->method('addError');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ define([
TOP: screen.height - 510 - 300
},

invokePopup: function (identityCallbackUrl, consumerId, jqInfoDialog) {
invokePopup: function (identityCallbackUrl, consumerKey, jqInfoDialog) {
// Callback should be invoked only once. Reset callback flag on subsequent invocations.
IdentityLogin.isCalledBack = false;
IdentityLogin.jqInfoDialog = jqInfoDialog;
var param = $.param({"consumer_id": consumerId, "success_call_back": IdentityLogin.successCallbackUrl});
var param = $.param({"oauth_consumer_key": consumerKey, "success_call_back": IdentityLogin.successCallbackUrl});
IdentityLogin.win = window.open(identityCallbackUrl + '?' + param, '',
'top=' + IdentityLogin.Constants.TOP +
', left=' + IdentityLogin.Constants.LEFT +
Expand Down Expand Up @@ -205,7 +205,7 @@ define([
}

var identityLinkUrl = null,
consumerId = null,
consumerKey = null,
popupHtml = null,
popup = $('#integration-popup-container');

Expand All @@ -215,15 +215,15 @@ define([
result;

identityLinkUrl = resultObj['identity_link_url'];
consumerId = resultObj['consumer_id'];
consumerKey = resultObj['oauth_consumer_key'];
popupHtml = resultObj['popup_content'];

} catch (e) {
//This is expected if result is not json. Do nothing.
}

if (identityLinkUrl && consumerId && popupHtml) {
IdentityLogin.invokePopup(identityLinkUrl, consumerId, popup);
if (identityLinkUrl && consumerKey && popupHtml) {
IdentityLogin.invokePopup(identityLinkUrl, consumerKey, popup);
} else {
popupHtml = result;
}
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Quote/Model/Cart/TotalsConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function __construct(
$this->factory = $factory;
}


/**
* @param \Magento\Quote\Model\Quote\Address\Total[] $addressTotals
* @return \Magento\Quote\Api\Data\TotalSegmentInterface[]
Expand All @@ -44,7 +43,7 @@ public function process($addressTotals)
TotalSegmentInterface::AREA => $addressTotal->getArea(),
];
if (is_object($addressTotal->getTitle())) {
$pureData[TotalSegmentInterface::TITLE] = $addressTotal->getTitle()->getText();
$pureData[TotalSegmentInterface::TITLE] = $addressTotal->getTitle()->render();
}
/** @var \Magento\Quote\Model\Cart\TotalSegment $total */
$total = $this->factory->create();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Sales\Model\ResourceModel\Order\Creditmemo\Grid;

use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Psr\Log\LoggerInterface as Logger;

class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
{
/**
* Initialize dependencies.
*
* @param EntityFactory $entityFactory
* @param Logger $logger
* @param FetchStrategy $fetchStrategy
* @param EventManager $eventManager
* @param string $mainTable
* @param string $resourceModel
*/
public function __construct(
EntityFactory $entityFactory,
Logger $logger,
FetchStrategy $fetchStrategy,
EventManager $eventManager,
$mainTable = 'sales_creditmemo_grid',
$resourceModel = '\Magento\Sales\Model\ResourceModel\Order\Creditmemo'
) {
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Sales\Model\ResourceModel\Order\Creditmemo\Order\Grid;

use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Psr\Log\LoggerInterface as Logger;

class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
{
/**
* Initialize dependencies.
*
* @param EntityFactory $entityFactory
* @param Logger $logger
* @param FetchStrategy $fetchStrategy
* @param EventManager $eventManager
* @param string $mainTable
* @param string $resourceModel
*/
public function __construct(
EntityFactory $entityFactory,
Logger $logger,
FetchStrategy $fetchStrategy,
EventManager $eventManager,
$mainTable = 'sales_creditmemo_grid',
$resourceModel = '\Magento\Sales\Model\ResourceModel\Order\Creditmemo'
) {
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Sales\Model\ResourceModel\Order\Invoice\Grid;

use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Psr\Log\LoggerInterface as Logger;

class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
{
/**
* Initialize dependencies.
*
* @param EntityFactory $entityFactory
* @param Logger $logger
* @param FetchStrategy $fetchStrategy
* @param EventManager $eventManager
* @param string $mainTable
* @param string $resourceModel
*/
public function __construct(
EntityFactory $entityFactory,
Logger $logger,
FetchStrategy $fetchStrategy,
EventManager $eventManager,
$mainTable = 'sales_invoice_grid',
$resourceModel = '\Magento\Sales\Model\ResourceModel\Order\Invoice'
) {
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Sales\Model\ResourceModel\Order\Invoice\Orders\Grid;

use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Psr\Log\LoggerInterface as Logger;

class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
{
/**
* Initialize dependencies.
*
* @param EntityFactory $entityFactory
* @param Logger $logger
* @param FetchStrategy $fetchStrategy
* @param EventManager $eventManager
* @param string $mainTable
* @param string $resourceModel
*/
public function __construct(
EntityFactory $entityFactory,
Logger $logger,
FetchStrategy $fetchStrategy,
EventManager $eventManager,
$mainTable = 'sales_invoice_grid',
$resourceModel = '\Magento\Sales\Model\ResourceModel\Order\Invoice'
) {
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Sales\Model\ResourceModel\Order\Shipment\Grid;

use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Psr\Log\LoggerInterface as Logger;

class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
{
/**
* Initialize dependencies.
*
* @param EntityFactory $entityFactory
* @param Logger $logger
* @param FetchStrategy $fetchStrategy
* @param EventManager $eventManager
* @param string $mainTable
* @param string $resourceModel
*/
public function __construct(
EntityFactory $entityFactory,
Logger $logger,
FetchStrategy $fetchStrategy,
EventManager $eventManager,
$mainTable = 'sales_shipment_grid',
$resourceModel = '\Magento\Sales\Model\ResourceModel\Order\Shipment'
) {
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
}
}
Loading

0 comments on commit d447fa6

Please sign in to comment.