Skip to content

Commit d24f988

Browse files
author
Igor Melnikov
committed
Merge branch 'MAGETWO-58633-eav' of github.com:magento-jackalopes/magento2ce into MAGETWO-58633-eav
2 parents 3b9269b + 9c9672e commit d24f988

File tree

221 files changed

+15617
-3816
lines changed

Some content is hidden

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

221 files changed

+15617
-3816
lines changed

app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Magento\Payment\Model\IframeConfigProvider;
1717
use Magento\Quote\Api\CartManagementInterface;
1818
use Magento\Framework\Exception\LocalizedException;
19+
use Psr\Log\LoggerInterface;
20+
use Magento\Framework\App\ObjectManager;
1921

2022
/**
2123
* Class Place
@@ -44,26 +46,36 @@ class Place extends Payment
4446
*/
4547
protected $jsonHelper;
4648

49+
/**
50+
* Logger for exception details
51+
*
52+
* @var LoggerInterface
53+
*/
54+
private $logger;
55+
4756
/**
4857
* @param Context $context
4958
* @param Registry $coreRegistry
5059
* @param DataFactory $dataFactory
5160
* @param CartManagementInterface $cartManagement
5261
* @param Onepage $onepageCheckout
5362
* @param JsonHelper $jsonHelper
63+
* @param LoggerInterface|null $logger
5464
*/
5565
public function __construct(
5666
Context $context,
5767
Registry $coreRegistry,
5868
DataFactory $dataFactory,
5969
CartManagementInterface $cartManagement,
6070
Onepage $onepageCheckout,
61-
JsonHelper $jsonHelper
71+
JsonHelper $jsonHelper,
72+
LoggerInterface $logger = null
6273
) {
6374
$this->eventManager = $context->getEventManager();
6475
$this->cartManagement = $cartManagement;
6576
$this->onepageCheckout = $onepageCheckout;
6677
$this->jsonHelper = $jsonHelper;
78+
$this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
6779
parent::__construct($context, $coreRegistry, $dataFactory);
6880
}
6981

@@ -127,9 +139,11 @@ protected function placeCheckoutOrder()
127139
]
128140
);
129141
} catch (LocalizedException $exception) {
142+
$this->logger->critical($exception);
130143
$result->setData('error', true);
131144
$result->setData('error_messages', $exception->getMessage());
132145
} catch (\Exception $exception) {
146+
$this->logger->critical($exception);
133147
$result->setData('error', true);
134148
$result->setData(
135149
'error_messages',

app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/PlaceTest.php

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Payment\Model\IframeConfigProvider;
2121
use Magento\Quote\Api\CartManagementInterface;
2222
use Magento\Quote\Model\Quote;
23+
use Magento\Framework\Exception\LocalizedException;
2324

2425
/**
2526
* Class PlaceTest
@@ -94,6 +95,11 @@ class PlaceTest extends \PHPUnit_Framework_TestCase
9495
*/
9596
protected $quoteMock;
9697

98+
/**
99+
* @var \PHPUnit_Framework_MockObject_MockObject
100+
*/
101+
private $loggerMock;
102+
97103
/**
98104
* @var CheckoutSession|\PHPUnit_Framework_MockObject_MockObject
99105
*/
@@ -152,6 +158,9 @@ protected function setUp()
152158
->getMockBuilder(\Magento\Framework\App\Response\Http::class)
153159
->disableOriginalConstructor()
154160
->getMockForAbstractClass();
161+
$this->loggerMock = $this
162+
->getMockBuilder(\Psr\Log\LoggerInterface::class)
163+
->getMock();
155164

156165
$this->objectManager = new ObjectManager($this);
157166
$this->placeOrderController = $this->objectManager->getObject(
@@ -165,6 +174,7 @@ protected function setUp()
165174
'cartManagement' => $this->cartManagementMock,
166175
'onepageCheckout' => $this->onepageCheckout,
167176
'jsonHelper' => $this->jsonHelperMock,
177+
'logger' => $this->loggerMock,
168178
]
169179
);
170180
}
@@ -214,13 +224,15 @@ public function testExecute(
214224
* @param $controller
215225
* @param $quoteId
216226
* @param $result
227+
* @param \Exception $exception Exception to check
217228
* @dataProvider textExecuteFailedPlaceOrderDataProvider
218229
*/
219230
public function testExecuteFailedPlaceOrder(
220231
$paymentMethod,
221232
$controller,
222233
$quoteId,
223-
$result
234+
$result,
235+
$exception
224236
) {
225237
$this->requestMock->expects($this->at(0))
226238
->method('getParam')
@@ -238,7 +250,11 @@ public function testExecuteFailedPlaceOrder(
238250

239251
$this->cartManagementMock->expects($this->once())
240252
->method('placeOrder')
241-
->willThrowException(new \Exception());
253+
->willThrowException($exception);
254+
255+
$this->loggerMock->expects($this->once())
256+
->method('critical')
257+
->with($exception);
242258

243259
$this->jsonHelperMock->expects($this->any())
244260
->method('jsonEncode')
@@ -278,19 +294,35 @@ public function textExecuteDataProvider()
278294
*/
279295
public function textExecuteFailedPlaceOrderDataProvider()
280296
{
281-
$objectFailed = new \Magento\Framework\DataObject();
282-
$objectFailed->setData('error', true);
283-
$objectFailed->setData(
284-
'error_messages',
285-
__('An error occurred on the server. Please try to place the order again.')
297+
$objectFailed1 = new \Magento\Framework\DataObject(
298+
[
299+
'error' => true,
300+
'error_messages' => __('An error occurred on the server. Please try to place the order again.')
301+
]
302+
);
303+
$generalException = new \Exception('Exception logging will save the world!');
304+
$localizedException = new LocalizedException(__('Electronic payments save the trees.'));
305+
$objectFailed2 = new \Magento\Framework\DataObject(
306+
[
307+
'error' => true,
308+
'error_messages' => $localizedException->getMessage()
309+
]
286310
);
287311

288312
return [
289313
[
290314
['method' => 'authorizenet_directpost'],
291315
IframeConfigProvider::CHECKOUT_IDENTIFIER,
292316
1,
293-
$objectFailed
317+
$objectFailed1,
318+
$generalException,
319+
],
320+
[
321+
['method' => 'authorizenet_directpost'],
322+
IframeConfigProvider::CHECKOUT_IDENTIFIER,
323+
1,
324+
$objectFailed2,
325+
$localizedException,
294326
],
295327
];
296328
}

app/code/Magento/Braintree/Controller/Paypal/PlaceOrder.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Magento\Framework\Controller\ResultFactory;
1212
use Magento\Framework\Exception\LocalizedException;
1313
use Magento\Braintree\Gateway\Config\PayPal\Config;
14+
use Psr\Log\LoggerInterface;
15+
use Magento\Framework\App\ObjectManager;
1416

1517
/**
1618
* Class PlaceOrder
@@ -22,22 +24,32 @@ class PlaceOrder extends AbstractAction
2224
*/
2325
private $orderPlace;
2426

27+
/**
28+
* Logger for exception details
29+
*
30+
* @var LoggerInterface
31+
*/
32+
private $logger;
33+
2534
/**
2635
* Constructor
2736
*
2837
* @param Context $context
2938
* @param Config $config
3039
* @param Session $checkoutSession
3140
* @param Helper\OrderPlace $orderPlace
41+
* @param LoggerInterface|null $logger
3242
*/
3343
public function __construct(
3444
Context $context,
3545
Config $config,
3646
Session $checkoutSession,
37-
Helper\OrderPlace $orderPlace
47+
Helper\OrderPlace $orderPlace,
48+
LoggerInterface $logger = null
3849
) {
3950
parent::__construct($context, $config, $checkoutSession);
4051
$this->orderPlace = $orderPlace;
52+
$this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
4153
}
4254

4355
/**
@@ -58,6 +70,7 @@ public function execute()
5870
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
5971
return $resultRedirect->setPath('checkout/onepage/success', ['_secure' => true]);
6072
} catch (\Exception $e) {
73+
$this->logger->critical($e);
6174
$this->messageManager->addExceptionMessage($e, $e->getMessage());
6275
}
6376

app/code/Magento/Braintree/Test/Unit/Controller/Paypal/PlaceOrderTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class PlaceOrderTest extends \PHPUnit_Framework_TestCase
6060
*/
6161
private $placeOrder;
6262

63+
/**
64+
* @var \PHPUnit_Framework_MockObject_MockObject
65+
*/
66+
private $loggerMock;
67+
6368
protected function setUp()
6469
{
6570
/** @var Context|\PHPUnit_Framework_MockObject_MockObject $contextMock */
@@ -94,11 +99,15 @@ protected function setUp()
9499
->method('getMessageManager')
95100
->willReturn($this->messageManagerMock);
96101

102+
$this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)
103+
->disableOriginalConstructor()
104+
->getMock();
97105
$this->placeOrder = new PlaceOrder(
98106
$contextMock,
99107
$this->configMock,
100108
$this->checkoutSessionMock,
101-
$this->orderPlaceMock
109+
$this->orderPlaceMock,
110+
$this->loggerMock
102111
);
103112
}
104113

app/code/Magento/Bundle/view/adminhtml/layout/adminhtml_order_shipment_view.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
1010
<referenceBlock name="shipment_items">
11-
<block class="Magento\Bundle\Block\Adminhtml\Sales\Order\Items\Renderer" name="shipment_item_bundle" as="shipment_item_bundle" template="sales/shipment/view/items/renderer.phtml"/>
11+
<block class="Magento\Bundle\Block\Adminhtml\Sales\Order\Items\Renderer" name="bundle" as="bundle" template="sales/shipment/view/items/renderer.phtml"/>
1212
</referenceBlock>
1313
</body>
1414
</page>

app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function execute()
162162
$this->attributeHelper->getStoreWebsiteId($storeId)
163163
);
164164
if (!$stockItemDo->getProductId()) {
165-
$inventoryData[] = $productId;
165+
$inventoryData['product_id'] = $productId;
166166
}
167167

168168
$stockItemId = $stockItemDo->getId();

app/code/Magento/Catalog/Model/Product/Attribute/Repository.php

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter
5050
*/
5151
protected $searchCriteriaBuilder;
5252

53-
/**
54-
* @var \Magento\Catalog\Api\ProductAttributeOptionManagementInterface
55-
*/
56-
private $optionManagement;
57-
5853
/**
5954
* @param \Magento\Catalog\Model\ResourceModel\Attribute $attributeResource
6055
* @param \Magento\Catalog\Helper\Product $productHelper
@@ -177,13 +172,31 @@ public function save(\Magento\Catalog\Api\Data\ProductAttributeInterface $attrib
177172
);
178173
$attribute->setIsUserDefined(1);
179174
}
180-
$this->attributeResource->save($attribute);
181-
182175
if (!empty($attribute->getData(AttributeInterface::OPTIONS))) {
176+
$options = [];
177+
$sortOrder = 0;
178+
$default = [];
179+
$optionIndex = 0;
183180
foreach ($attribute->getOptions() as $option) {
184-
$this->getOptionManagement()->add($attribute->getAttributeCode(), $option);
181+
$optionIndex++;
182+
$optionId = $option->getValue() ?: 'option_' . $optionIndex;
183+
$options['value'][$optionId][0] = $option->getLabel();
184+
$options['order'][$optionId] = $option->getSortOrder() ?: $sortOrder++;
185+
if (is_array($option->getStoreLabels())) {
186+
foreach ($option->getStoreLabels() as $label) {
187+
$options['value'][$optionId][$label->getStoreId()] = $label->getLabel();
188+
}
189+
}
190+
if ($option->getIsDefault()) {
191+
$default[] = $optionId;
192+
}
193+
}
194+
$attribute->setDefault($default);
195+
if (count($options)) {
196+
$attribute->setOption($options);
185197
}
186198
}
199+
$this->attributeResource->save($attribute);
187200
return $this->get($attribute->getAttributeCode());
188201
}
189202

@@ -262,16 +275,4 @@ protected function validateFrontendInput($frontendInput)
262275
throw InputException::invalidFieldValue('frontend_input', $frontendInput);
263276
}
264277
}
265-
266-
/**
267-
* @return \Magento\Catalog\Api\ProductAttributeOptionManagementInterface
268-
*/
269-
private function getOptionManagement()
270-
{
271-
if (null === $this->optionManagement) {
272-
$this->optionManagement = \Magento\Framework\App\ObjectManager::getInstance()
273-
->get(\Magento\Catalog\Api\ProductAttributeOptionManagementInterface::class);
274-
}
275-
return $this->optionManagement;
276-
}
277278
}

app/code/Magento/Catalog/view/frontend/templates/product/list/items.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ switch ($type = $block->getType()) {
110110

111111
case 'crosssell':
112112
/** @var \Magento\Catalog\Block\Product\ProductList\Crosssell $block */
113-
if ($exist = $block->getItemCount()) {
113+
if ($exist = count($block->getItems())) {
114114
$type = 'crosssell';
115115
$class = $type;
116116

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ protected function _initAttributeSets()
10151015
protected function _initSkus()
10161016
{
10171017
$this->skuProcessor->setTypeModels($this->_productTypeModels);
1018-
$this->_oldSku = $this->skuProcessor->getOldSkus();
1018+
$this->_oldSku = $this->skuProcessor->reloadOldSkus()->getOldSkus();
10191019
return $this;
10201020
}
10211021

app/code/Magento/CatalogImportExport/Model/Import/Uploader.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\CatalogImportExport\Model\Import;
77

88
use Magento\Framework\App\Filesystem\DirectoryList;
9+
use Magento\Framework\Exception\LocalizedException;
910
use Magento\Framework\Filesystem\DriverPool;
1011

1112
/**
@@ -15,6 +16,14 @@
1516
*/
1617
class Uploader extends \Magento\MediaStorage\Model\File\Uploader
1718
{
19+
20+
/**
21+
* HTTP scheme
22+
* used to compare against the filename and select the proper DriverPool adapter
23+
* @var string
24+
*/
25+
private $httpScheme = 'http://';
26+
1827
/**
1928
* Temp directory.
2029
*
@@ -145,7 +154,13 @@ public function move($fileName, $renameFileOff = false)
145154
}
146155
if (preg_match('/\bhttps?:\/\//i', $fileName, $matches)) {
147156
$url = str_replace($matches[0], '', $fileName);
148-
$read = $this->_readFactory->create($url, DriverPool::HTTP);
157+
158+
if ($matches[0] === $this->httpScheme) {
159+
$read = $this->_readFactory->create($url, DriverPool::HTTP);
160+
} else {
161+
$read = $this->_readFactory->create($url, DriverPool::HTTPS);
162+
}
163+
149164
$fileName = preg_replace('/[^a-z0-9\._-]+/i', '', $fileName);
150165
$this->_directory->writeFile(
151166
$this->_directory->getRelativePath($this->getTmpDir() . '/' . $fileName),

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ protected function _initTypeModels()
516516
protected function _initSkus()
517517
{
518518
$this->skuProcessor->expects($this->once())->method('setTypeModels');
519+
$this->skuProcessor->expects($this->once())->method('reloadOldSkus')->willReturnSelf();
519520
$this->skuProcessor->expects($this->once())->method('getOldSkus');
520521
return $this;
521522
}

0 commit comments

Comments
 (0)