Skip to content

Commit 0d6b36b

Browse files
author
Volodymyr Kublytskyi
authored
Merge pull request #1702 from magento-partners/prs-2.2-2017-11-10
[EngCom] Partners Pull Requests
2 parents 758ba75 + c5fa96e commit 0d6b36b

File tree

15 files changed

+136
-119
lines changed

15 files changed

+136
-119
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ protected function _createTemporaryFlatTable($storeId)
179179

180180
$columnComment = isset($fieldProp['comment']) ? $fieldProp['comment'] : $fieldName;
181181

182+
if ($fieldName == 'created_at') {
183+
$columnDefinition['nullable'] = true;
184+
$columnDefinition['default'] = null;
185+
}
186+
182187
$table->addColumn($fieldName, $fieldProp['type'], $columnLength, $columnDefinition, $columnComment);
183188
}
184189

app/code/Magento/Customer/Api/CustomerRepositoryInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function save(\Magento\Customer\Api\Data\CustomerInterface $customer, $pa
3838
public function get($email, $websiteId = null);
3939

4040
/**
41-
* Get customer by customer ID.
41+
* Get customer by Customer ID.
4242
*
4343
* @param int $customerId
4444
* @return \Magento\Customer\Api\Data\CustomerInterface
@@ -70,7 +70,7 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
7070
public function delete(\Magento\Customer\Api\Data\CustomerInterface $customer);
7171

7272
/**
73-
* Delete customer by ID.
73+
* Delete customer by Customer ID.
7474
*
7575
* @param int $customerId
7676
* @return bool true on success

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,8 @@ public function initiatePasswordReset($email, $template, $websiteId = null)
531531
$this->getEmailNotification()->passwordResetConfirmation($customer);
532532
break;
533533
default:
534-
throw new InputException(
535-
__(
536-
'Invalid value of "%value" provided for the %fieldName field.',
537-
['value' => $template, 'fieldName' => 'email type']
538-
)
539-
);
534+
$this->handleUnknownTemplate($template);
535+
break;
540536
}
541537
return true;
542538
} catch (MailException $e) {
@@ -546,6 +542,25 @@ public function initiatePasswordReset($email, $template, $websiteId = null)
546542
return false;
547543
}
548544

545+
/**
546+
* Handle not supported template
547+
*
548+
* @param string $template
549+
* @throws InputException
550+
*/
551+
private function handleUnknownTemplate($template)
552+
{
553+
throw new InputException(__(
554+
'Invalid value of "%value" provided for the %fieldName field. Possible values: %template1 or %template2.',
555+
[
556+
'value' => $template,
557+
'fieldName' => 'template',
558+
'template1' => AccountManagement::EMAIL_REMINDER,
559+
'template2' => AccountManagement::EMAIL_RESET
560+
]
561+
));
562+
}
563+
549564
/**
550565
* {@inheritdoc}
551566
*/

app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,10 +1173,6 @@ public function testInitiatePasswordResetEmailReset()
11731173
$this->assertTrue($this->accountManagement->initiatePasswordReset($email, $template));
11741174
}
11751175

1176-
/**
1177-
* @expectedException \Magento\Framework\Exception\InputException
1178-
* @expectedExceptionMessage Invalid value of "" provided for the email type field
1179-
*/
11801176
public function testInitiatePasswordResetNoTemplate()
11811177
{
11821178
$storeId = 1;
@@ -1192,6 +1188,10 @@ public function testInitiatePasswordResetNoTemplate()
11921188

11931189
$this->prepareInitiatePasswordReset($email, $templateIdentifier, $sender, $storeId, $customerId, $hash);
11941190

1191+
$this->expectException(\Magento\Framework\Exception\InputException::class);
1192+
$this->expectExceptionMessage(
1193+
'Invalid value of "" provided for the template field. Possible values: email_reminder or email_reset.'
1194+
);
11951195
$this->accountManagement->initiatePasswordReset($email, $template);
11961196
}
11971197

app/code/Magento/Customer/etc/webapi.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
<resource ref="anonymous"/>
129129
</resources>
130130
</route>
131-
<route url="/V1/customers/:id" method="PUT">
131+
<route url="/V1/customers/:customerId" method="PUT">
132132
<service class="Magento\Customer\Api\CustomerRepositoryInterface" method="save"/>
133133
<resources>
134134
<resource ref="Magento_Customer::manage"/>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\InstantPurchase\Model\ShippingMethodChoose;
7+
8+
use Magento\Customer\Model\Address;
9+
use Magento\Framework\DataObject;
10+
use Magento\Shipping\Model\Config as CarriersConfig;
11+
use Magento\Store\Model\StoreManagerInterface;
12+
13+
/**
14+
* Collect shipping rates for customer address without packaging estiamtion.
15+
*/
16+
class CarrierFinder
17+
{
18+
/**
19+
* @var CarriersConfig
20+
*/
21+
private $carriersConfig;
22+
23+
/**
24+
* @var StoreManagerInterface
25+
*/
26+
private $storeManager;
27+
28+
/**
29+
* CarrierFinder constructor.
30+
* @param CarriersConfig $carriersConfig
31+
* @param StoreManagerInterface $storeManager
32+
*/
33+
public function __construct(
34+
CarriersConfig $carriersConfig,
35+
StoreManagerInterface $storeManager
36+
) {
37+
$this->carriersConfig = $carriersConfig;
38+
$this->storeManager = $storeManager;
39+
}
40+
41+
/**
42+
* Finds carriers delivering to customer address
43+
*
44+
* @param Address $address
45+
* @return array
46+
*/
47+
public function getCarriersForCustomerAddress(Address $address): array
48+
{
49+
$request = new DataObject([
50+
'dest_country_id' => $address->getCountryId()
51+
]);
52+
53+
$carriers = [];
54+
foreach ($this->carriersConfig->getActiveCarriers($this->storeManager->getStore()->getId()) as $carrier) {
55+
$checked = $carrier->checkAvailableShipCountries($request);
56+
if (false !== $checked && null === $checked->getErrorMessage() && !empty($checked->getAllowedMethods())) {
57+
$carriers[] = $checked;
58+
}
59+
}
60+
61+
return $carriers;
62+
}
63+
}

app/code/Magento/InstantPurchase/Model/ShippingMethodChoose/CheapestMethodChooser.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
namespace Magento\InstantPurchase\Model\ShippingMethodChoose;
77

88
use Magento\Customer\Model\Address;
9-
use Magento\Quote\Api\Data\ShippingMethodInterface;
109
use Magento\Quote\Api\Data\ShippingMethodInterfaceFactory;
1110

1211
/**
@@ -20,21 +19,21 @@ class CheapestMethodChooser implements ShippingMethodChooserInterface
2019
private $shippingMethodFactory;
2120

2221
/**
23-
* @var ShippingRateFinder
22+
* @var CarrierFinder
2423
*/
25-
private $shippingRateFinder;
24+
private $carrierFinder;
2625

2726
/**
2827
* CheapestMethodChooser constructor.
2928
* @param ShippingMethodInterfaceFactory $shippingMethodFactory
30-
* @param ShippingRateFinder $shippingRateFinder
29+
* @param CarrierFinder $carrierFinder
3130
*/
3231
public function __construct(
3332
ShippingMethodInterfaceFactory $shippingMethodFactory,
34-
ShippingRateFinder $shippingRateFinder
33+
CarrierFinder $carrierFinder
3534
) {
3635
$this->shippingMethodFactory = $shippingMethodFactory;
37-
$this->shippingRateFinder = $shippingRateFinder;
36+
$this->carrierFinder = $carrierFinder;
3837
}
3938

4039
/**
@@ -58,7 +57,7 @@ public function choose(Address $address)
5857
*/
5958
private function areShippingMethodsAvailable(Address $address): bool
6059
{
61-
$shippingRatesForAddress = $this->shippingRateFinder->getRatesForCustomerAddress($address);
62-
return !empty($shippingRatesForAddress);
60+
$carriersForAddress = $this->carrierFinder->getCarriersForCustomerAddress($address);
61+
return !empty($carriersForAddress);
6362
}
6463
}

app/code/Magento/InstantPurchase/Model/ShippingMethodChoose/ShippingRateFinder.php

Lines changed: 0 additions & 81 deletions
This file was deleted.

app/code/Magento/InstantPurchase/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"magento/module-catalog": "102.0.*",
1414
"magento/module-customer": "101.0.*",
1515
"magento/module-sales": "101.0.*",
16+
"magento/module-shipping": "100.2.*",
1617
"magento/module-quote": "101.0.*",
1718
"magento/module-vault": "101.0.*",
1819
"magento/framework": "100.2.*"

app/code/Magento/Tax/Model/Plugin/OrderSave.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ protected function saveOrderTax(\Magento\Sales\Api\Data\OrderInterface $order)
163163
if (isset($quoteItemId['id'])) {
164164
//This is a product item
165165
$item = $order->getItemByQuoteItemId($quoteItemId['id']);
166-
$itemId = $item->getId();
166+
if ($item !== null && $item->getId()) {
167+
$itemId = $item->getId();
168+
}
167169
} elseif (isset($quoteItemId['associated_item_id'])) {
168170
//This item is associated with a product item
169171
$item = $order->getItemByQuoteItemId($quoteItemId['associated_item_id']);

app/code/Magento/Webapi/Model/Rest/Swagger/Generator.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,17 @@ protected function getGeneralInfo()
204204
protected function generatePathInfo($methodName, $httpMethodData, $tagName)
205205
{
206206
$methodData = $httpMethodData[Converter::KEY_METHOD];
207+
208+
$operationId = $this->typeProcessor->getOperationName($tagName, $methodData[Converter::KEY_METHOD]);
209+
$operationId .= ucfirst($methodName);
210+
207211
$pathInfo = [
208212
'tags' => [$tagName],
209213
'description' => $methodData['documentation'],
210-
'operationId' => $this->typeProcessor->getOperationName($tagName, $methodData[Converter::KEY_METHOD]) .
211-
ucfirst($methodName)
214+
'operationId' => $operationId,
212215
];
213216

214-
$parameters = $this->generateMethodParameters($httpMethodData);
217+
$parameters = $this->generateMethodParameters($httpMethodData, $operationId);
215218
if ($parameters) {
216219
$pathInfo['parameters'] = $parameters;
217220
}
@@ -265,11 +268,12 @@ protected function generateMethodResponses($methodData)
265268
* Generate parameters based on method data
266269
*
267270
* @param array $httpMethodData
271+
* @param string $operationId
268272
* @return array
269273
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
270274
* @SuppressWarnings(PHPMD.NPathComplexity)
271275
*/
272-
private function generateMethodParameters($httpMethodData)
276+
private function generateMethodParameters($httpMethodData, $operationId)
273277
{
274278
$bodySchema = [];
275279
$parameters = [];
@@ -335,7 +339,7 @@ private function generateMethodParameters($httpMethodData)
335339

336340
if ($bodySchema) {
337341
$bodyParam = [];
338-
$bodyParam['name'] = '$body';
342+
$bodyParam['name'] = $operationId . 'Body';
339343
$bodyParam['in'] = 'body';
340344
$bodyParam['schema'] = $bodySchema;
341345
$parameters[] = $bodyParam;

app/code/Magento/Webapi/Test/Unit/Model/Rest/Swagger/GeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public function generateDataProvider()
223223
]
224224
],
225225
// @codingStandardsIgnoreStart
226-
'{"swagger":"2.0","info":{"version":"","title":""},"host":"magento.host","basePath":"/rest/default","schemes":["http://"],"tags":[{"name":"testModule5AllSoapAndRestV2","description":"AllSoapAndRestInterface"}],"paths":{"/V1/testModule5":{"post":{"tags":["testModule5AllSoapAndRestV2"],"description":"Add new item.","operationId":"' . self::OPERATION_NAME . 'Post","parameters":[{"name":"$body","in":"body","schema":{"required":["item"],"properties":{"item":{"$ref":"#/definitions/test-module5-v2-entity-all-soap-and-rest"}},"type":"object"}}],"responses":{"200":{"description":"200 Success.","schema":{"$ref":"#/definitions/test-module5-v2-entity-all-soap-and-rest"}},"401":{"description":"401 Unauthorized","schema":{"$ref":"#/definitions/error-response"}},"500":{"description":"Internal Server error","schema":{"$ref":"#/definitions/error-response"}},"default":{"description":"Unexpected error","schema":{"$ref":"#/definitions/error-response"}}}}}},"definitions":{"error-response":{"type":"object","properties":{"message":{"type":"string","description":"Error message"},"errors":{"$ref":"#/definitions/error-errors"},"code":{"type":"integer","description":"Error code"},"parameters":{"$ref":"#/definitions/error-parameters"},"trace":{"type":"string","description":"Stack trace"}},"required":["message"]},"error-errors":{"type":"array","description":"Errors list","items":{"$ref":"#/definitions/error-errors-item"}},"error-errors-item":{"type":"object","description":"Error details","properties":{"message":{"type":"string","description":"Error message"},"parameters":{"$ref":"#/definitions/error-parameters"}}},"error-parameters":{"type":"array","description":"Error parameters list","items":{"$ref":"#/definitions/error-parameters-item"}},"error-parameters-item":{"type":"object","description":"Error parameters item","properties":{"resources":{"type":"string","description":"ACL resource"},"fieldName":{"type":"string","description":"Missing or invalid field name"},"fieldValue":{"type":"string","description":"Incorrect field value"}}},"test-module5-v2-entity-all-soap-and-rest":{"type":"object","description":"Some Data Object","properties":{"price":{"type":"integer"}},"required":["price"]}}}'
226+
'{"swagger":"2.0","info":{"version":"","title":""},"host":"magento.host","basePath":"/rest/default","schemes":["http://"],"tags":[{"name":"testModule5AllSoapAndRestV2","description":"AllSoapAndRestInterface"}],"paths":{"/V1/testModule5":{"post":{"tags":["testModule5AllSoapAndRestV2"],"description":"Add new item.","operationId":"' . self::OPERATION_NAME . 'Post","parameters":[{"name":"operationNamePostBody","in":"body","schema":{"required":["item"],"properties":{"item":{"$ref":"#/definitions/test-module5-v2-entity-all-soap-and-rest"}},"type":"object"}}],"responses":{"200":{"description":"200 Success.","schema":{"$ref":"#/definitions/test-module5-v2-entity-all-soap-and-rest"}},"401":{"description":"401 Unauthorized","schema":{"$ref":"#/definitions/error-response"}},"500":{"description":"Internal Server error","schema":{"$ref":"#/definitions/error-response"}},"default":{"description":"Unexpected error","schema":{"$ref":"#/definitions/error-response"}}}}}},"definitions":{"error-response":{"type":"object","properties":{"message":{"type":"string","description":"Error message"},"errors":{"$ref":"#/definitions/error-errors"},"code":{"type":"integer","description":"Error code"},"parameters":{"$ref":"#/definitions/error-parameters"},"trace":{"type":"string","description":"Stack trace"}},"required":["message"]},"error-errors":{"type":"array","description":"Errors list","items":{"$ref":"#/definitions/error-errors-item"}},"error-errors-item":{"type":"object","description":"Error details","properties":{"message":{"type":"string","description":"Error message"},"parameters":{"$ref":"#/definitions/error-parameters"}}},"error-parameters":{"type":"array","description":"Error parameters list","items":{"$ref":"#/definitions/error-parameters-item"}},"error-parameters-item":{"type":"object","description":"Error parameters item","properties":{"resources":{"type":"string","description":"ACL resource"},"fieldName":{"type":"string","description":"Missing or invalid field name"},"fieldValue":{"type":"string","description":"Incorrect field value"}}},"test-module5-v2-entity-all-soap-and-rest":{"type":"object","description":"Some Data Object","properties":{"price":{"type":"integer"}},"required":["price"]}}}'
227227
// @codingStandardsIgnoreEnd
228228
],
229229
[

dev/tests/api-functional/testsuite/Magento/Webapi/JsonGenerationFromDataObjectTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Magento\TestFramework\Helper\Bootstrap;
1212
use Magento\Framework\App\ProductMetadataInterface;
13+
use Magento\Store\Model\StoreManagerInterface;
1314

1415
/**
1516
* Test REST schema generation mechanisms.
@@ -34,10 +35,10 @@ protected function setUp()
3435
{
3536
$this->_markTestAsRestOnly("JSON generation tests are intended to be executed for REST adapter only.");
3637

37-
$this->storeCode = Bootstrap::getObjectManager()->get(\Magento\Store\Model\StoreManagerInterface::class)
38+
$this->storeCode = Bootstrap::getObjectManager()->get(StoreManagerInterface::class)
3839
->getStore()->getCode();
3940

40-
$this->productMetadata = Bootstrap::getObjectManager()->get(\Magento\Framework\App\ProductMetadataInterface::class);
41+
$this->productMetadata = Bootstrap::getObjectManager()->get(ProductMetadataInterface::class);
4142

4243
parent::setUp();
4344
}
@@ -197,7 +198,7 @@ public function getExpectedMultiServiceData()
197198
'required' => true
198199
],
199200
[
200-
'name' => '$body',
201+
'name' => 'testModule5AllSoapAndRestV1NestedUpdatePutBody',
201202
'in' => 'body',
202203
'schema' => [
203204
'required' => [

0 commit comments

Comments
 (0)