Skip to content

Commit 190a4a4

Browse files
author
Oleksii Korshenko
authored
Merge pull request magento#1594 from magento-engcom/2.2-develop-prs
Public Pull Requests magento#11505 magento#11381 magento#11460 magento#11299 magento#11199
2 parents 080a341 + 1af3192 commit 190a4a4

File tree

6 files changed

+104
-10
lines changed

6 files changed

+104
-10
lines changed

app/code/Magento/Cron/etc/cron_groups.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<schedule_ahead_for>20</schedule_ahead_for>
1212
<schedule_lifetime>15</schedule_lifetime>
1313
<history_cleanup_every>10</history_cleanup_every>
14-
<history_success_lifetime>60</history_success_lifetime>
15-
<history_failure_lifetime>600</history_failure_lifetime>
14+
<history_success_lifetime>10080</history_success_lifetime>
15+
<history_failure_lifetime>10080</history_failure_lifetime>
1616
<use_separate_process>0</use_separate_process>
1717
</group>
1818
</config>

app/code/Magento/Indexer/etc/cron_groups.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<schedule_ahead_for>4</schedule_ahead_for>
1212
<schedule_lifetime>2</schedule_lifetime>
1313
<history_cleanup_every>10</history_cleanup_every>
14-
<history_success_lifetime>60</history_success_lifetime>
15-
<history_failure_lifetime>600</history_failure_lifetime>
14+
<history_success_lifetime>10080</history_success_lifetime>
15+
<history_failure_lifetime>10080</history_failure_lifetime>
1616
<use_separate_process>1</use_separate_process>
1717
</group>
1818
</config>

app/code/Magento/Sales/Controller/Adminhtml/Order/AddressSave.php

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,29 @@
66
*/
77
namespace Magento\Sales\Controller\Adminhtml\Order;
88

9-
class AddressSave extends \Magento\Sales\Controller\Adminhtml\Order
9+
use Magento\Backend\App\Action\Context;
10+
use Magento\Backend\Model\View\Result\Redirect;
11+
use Magento\Directory\Model\RegionFactory;
12+
use Magento\Sales\Api\OrderManagementInterface;
13+
use Magento\Sales\Api\OrderRepositoryInterface;
14+
use Magento\Sales\Api\Data\OrderAddressInterface;
15+
use Magento\Sales\Controller\Adminhtml\Order;
16+
use Magento\Sales\Model\Order\Address as AddressModel;
17+
use Psr\Log\LoggerInterface;
18+
use Magento\Framework\Registry;
19+
use Magento\Framework\App\Response\Http\FileFactory;
20+
use Magento\Framework\Translate\InlineInterface;
21+
use Magento\Framework\View\Result\PageFactory;
22+
use Magento\Framework\Controller\Result\JsonFactory;
23+
use Magento\Framework\View\Result\LayoutFactory;
24+
use Magento\Framework\Controller\Result\RawFactory;
25+
use Magento\Framework\Exception\LocalizedException;
26+
use Magento\Framework\App\ObjectManager;
27+
28+
/**
29+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
30+
*/
31+
class AddressSave extends Order
1032
{
1133
/**
1234
* Authorization level of a basic admin session
@@ -15,19 +37,70 @@ class AddressSave extends \Magento\Sales\Controller\Adminhtml\Order
1537
*/
1638
const ADMIN_RESOURCE = 'Magento_Sales::actions_edit';
1739

40+
/**
41+
* @var RegionFactory
42+
*/
43+
private $regionFactory;
44+
/**
45+
* @param Context $context
46+
* @param Registry $coreRegistry
47+
* @param FileFactory $fileFactory
48+
* @param InlineInterface $translateInline
49+
* @param PageFactory $resultPageFactory
50+
* @param JsonFactory $resultJsonFactory
51+
* @param LayoutFactory $resultLayoutFactory
52+
* @param RawFactory $resultRawFactory
53+
* @param OrderManagementInterface $orderManagement
54+
* @param OrderRepositoryInterface $orderRepository
55+
* @param LoggerInterface $logger
56+
* @param RegionFactory|null $regionFactory
57+
*
58+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
59+
*/
60+
public function __construct(
61+
Context $context,
62+
Registry $coreRegistry,
63+
FileFactory $fileFactory,
64+
InlineInterface $translateInline,
65+
PageFactory $resultPageFactory,
66+
JsonFactory $resultJsonFactory,
67+
LayoutFactory $resultLayoutFactory,
68+
RawFactory $resultRawFactory,
69+
OrderManagementInterface $orderManagement,
70+
OrderRepositoryInterface $orderRepository,
71+
LoggerInterface $logger,
72+
RegionFactory $regionFactory = null
73+
) {
74+
$this->regionFactory = $regionFactory ?: ObjectManager::getInstance()->get(RegionFactory::class);
75+
parent::__construct(
76+
$context,
77+
$coreRegistry,
78+
$fileFactory,
79+
$translateInline,
80+
$resultPageFactory,
81+
$resultJsonFactory,
82+
$resultLayoutFactory,
83+
$resultRawFactory,
84+
$orderManagement,
85+
$orderRepository,
86+
$logger
87+
);
88+
}
89+
1890
/**
1991
* Save order address
2092
*
21-
* @return \Magento\Backend\Model\View\Result\Redirect
93+
* @return Redirect
2294
*/
2395
public function execute()
2496
{
2597
$addressId = $this->getRequest()->getParam('address_id');
26-
/** @var $address \Magento\Sales\Api\Data\OrderAddressInterface|\Magento\Sales\Model\Order\Address */
98+
/** @var $address OrderAddressInterface|AddressModel */
2799
$address = $this->_objectManager->create(
28-
\Magento\Sales\Api\Data\OrderAddressInterface::class
100+
OrderAddressInterface::class
29101
)->load($addressId);
30102
$data = $this->getRequest()->getPostValue();
103+
$data = $this->updateRegionData($data);
31104
$resultRedirect = $this->resultRedirectFactory->create();
32105
if ($data && $address->getId()) {
33106
$address->addData($data);
@@ -41,7 +114,7 @@ public function execute()
41114
);
42115
$this->messageManager->addSuccess(__('You updated the order address.'));
43116
return $resultRedirect->setPath('sales/*/view', ['order_id' => $address->getParentId()]);
44-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
117+
} catch (LocalizedException $e) {
45118
$this->messageManager->addError($e->getMessage());
46119
} catch (\Exception $e) {
47120
$this->messageManager->addException($e, __('We can\'t update the order address right now.'));
@@ -51,4 +124,20 @@ public function execute()
51124
return $resultRedirect->setPath('sales/*/');
52125
}
53126
}
127+
128+
/**
129+
* Update region data
130+
*
131+
* @param array $attributeValues
132+
* @return array
133+
*/
134+
private function updateRegionData($attributeValues)
135+
{
136+
if (!empty($attributeValues['region_id'])) {
137+
$newRegion = $this->regionFactory->create()->load($attributeValues['region_id']);
138+
$attributeValues['region_code'] = $newRegion->getCode();
139+
$attributeValues['region'] = $newRegion->getDefaultName();
140+
}
141+
return $attributeValues;
142+
}
54143
}

app/code/Magento/Sales/Helper/Guest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ public function loadValidOrder(App\RequestInterface $request)
178178
public function getBreadcrumbs(\Magento\Framework\View\Result\Page $resultPage)
179179
{
180180
$breadcrumbs = $resultPage->getLayout()->getBlock('breadcrumbs');
181+
if (!$breadcrumbs) {
182+
return;
183+
}
181184
$breadcrumbs->addCrumb(
182185
'home',
183186
[

app/code/Magento/Store/App/Request/PathInfoProcessor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Store\App\Request;
77

88
use Magento\Framework\Exception\NoSuchEntityException;
9+
use Magento\Store\Model\Store;
910

1011
class PathInfoProcessor implements \Magento\Framework\App\Request\PathInfoProcessorInterface
1112
{
@@ -42,7 +43,7 @@ public function process(\Magento\Framework\App\RequestInterface $request, $pathI
4243
}
4344

4445
if ($store->isUseStoreInUrl()) {
45-
if (!$request->isDirectAccessFrontendName($storeCode)) {
46+
if (!$request->isDirectAccessFrontendName($storeCode) && $storeCode != Store::ADMIN_CODE) {
4647
$this->storeManager->setCurrentStore($storeCode);
4748
$pathInfo = '/' . (isset($pathParts[1]) ? $pathParts[1] : '');
4849
return $pathInfo;

setup/src/Magento/Setup/Model/Installer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,7 @@ private function installOrderIncrementPrefix($orderIncrementPrefix)
10101010
public function installAdminUser($data)
10111011
{
10121012
$this->assertDbConfigExists();
1013+
$data += ['db-prefix' => $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_PREFIX)];
10131014
$setup = $this->setupFactory->create($this->context->getResources());
10141015
$adminAccount = $this->adminAccountFactory->create($setup->getConnection(), (array)$data);
10151016
$adminAccount->save();

0 commit comments

Comments
 (0)