Skip to content

Commit a360c06

Browse files
authored
Merge pull request #5988 from magento-engcom/MC-36526
MC-36526: Revert public PR:27340
2 parents be26941 + 61ff26f commit a360c06

File tree

39 files changed

+568
-151
lines changed

39 files changed

+568
-151
lines changed

app/code/Magento/Customer/Block/Account/Navigation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ public function getLinks()
4747
*/
4848
private function compare(SortLinkInterface $firstLink, SortLinkInterface $secondLink): int
4949
{
50-
return $firstLink->getSortOrder() <=> $secondLink->getSortOrder();
50+
return $secondLink->getSortOrder() <=> $firstLink->getSortOrder();
5151
}
5252
}

app/code/Magento/Customer/Test/Unit/Block/Account/NavigationTest.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818

1919
class NavigationTest extends TestCase
2020
{
21-
/**
22-
* Stub name top links
23-
*/
24-
private const STUB_TOP_LINKS_NAME_IN_LAYOUT = 'top.links';
25-
2621
/**
2722
* @var ObjectManagerHelper
2823
*/
@@ -67,7 +62,7 @@ protected function setUp(): void
6762
*
6863
* @return void
6964
*/
70-
public function testGetLinksWithCustomerAndWishList(): void
65+
public function testGetLinksWithCustomerAndWishList()
7166
{
7267
$wishListLinkMock = $this->getMockBuilder(WishListLink::class)
7368
->disableOriginalConstructor()
@@ -81,30 +76,30 @@ public function testGetLinksWithCustomerAndWishList(): void
8176

8277
$wishListLinkMock->expects($this->any())
8378
->method('getSortOrder')
84-
->willReturn(30);
79+
->willReturn(100);
8580

8681
$customerAccountLinkMock->expects($this->any())
8782
->method('getSortOrder')
88-
->willReturn(0);
83+
->willReturn(20);
8984

90-
$topLinksNameInLayout = self::STUB_TOP_LINKS_NAME_IN_LAYOUT;
85+
$nameInLayout = 'top.links';
9186

9287
$blockChildren = [
93-
'customerAccountLink' => $customerAccountLinkMock,
94-
'wishListLink' => $wishListLinkMock
88+
'wishListLink' => $wishListLinkMock,
89+
'customerAccountLink' => $customerAccountLinkMock
9590
];
9691

97-
$this->navigation->setNameInLayout($topLinksNameInLayout);
92+
$this->navigation->setNameInLayout($nameInLayout);
9893
$this->layoutMock->expects($this->any())
9994
->method('getChildBlocks')
100-
->with($topLinksNameInLayout)
95+
->with($nameInLayout)
10196
->willReturn($blockChildren);
10297

10398
/* Assertion */
10499
$this->assertEquals(
105100
[
106-
0 => $customerAccountLinkMock,
107-
1 => $wishListLinkMock
101+
0 => $wishListLinkMock,
102+
1 => $customerAccountLinkMock
108103
],
109104
$this->navigation->getLinks()
110105
);

app/code/Magento/Customer/view/frontend/layout/customer_account.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,31 @@
2424
<arguments>
2525
<argument name="label" xsi:type="string" translate="true">My Account</argument>
2626
<argument name="path" xsi:type="string">customer/account</argument>
27-
<argument name="sortOrder" xsi:type="number">1</argument>
27+
<argument name="sortOrder" xsi:type="number">250</argument>
2828
</arguments>
2929
</block>
3030
<block class="Magento\Customer\Block\Account\Delimiter" name="customer-account-navigation-delimiter-1" template="Magento_Customer::account/navigation-delimiter.phtml">
3131
<arguments>
32-
<argument name="sortOrder" xsi:type="number">40</argument>
32+
<argument name="sortOrder" xsi:type="number">200</argument>
3333
</arguments>
3434
</block>
3535
<block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-address-link">
3636
<arguments>
3737
<argument name="label" xsi:type="string" translate="true">Address Book</argument>
3838
<argument name="path" xsi:type="string">customer/address</argument>
39-
<argument name="sortOrder" xsi:type="number">50</argument>
39+
<argument name="sortOrder" xsi:type="number">190</argument>
4040
</arguments>
4141
</block>
4242
<block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-account-edit-link">
4343
<arguments>
4444
<argument name="label" xsi:type="string" translate="true">Account Information</argument>
4545
<argument name="path" xsi:type="string">customer/account/edit</argument>
46-
<argument name="sortOrder" xsi:type="number">60</argument>
46+
<argument name="sortOrder" xsi:type="number">180</argument>
4747
</arguments>
4848
</block>
4949
<block class="Magento\Customer\Block\Account\Delimiter" name="customer-account-navigation-delimiter-2" template="Magento_Customer::account/navigation-delimiter.phtml">
5050
<arguments>
51-
<argument name="sortOrder" xsi:type="number">90</argument>
51+
<argument name="sortOrder" xsi:type="number">130</argument>
5252
</arguments>
5353
</block>
5454
</block>

app/code/Magento/Customer/view/frontend/layout/default.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
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="top.links">
11-
<block class="Magento\Customer\Block\Account\Link" name="my-account-link" template="Magento_Customer::account/link/my-account.phtml">
11+
<block class="Magento\Customer\Block\Account\Link" name="my-account-link">
1212
<arguments>
1313
<argument name="label" xsi:type="string" translate="true">My Account</argument>
14-
<argument name="sortOrder" xsi:type="number">1</argument>
14+
<argument name="sortOrder" xsi:type="number">110</argument>
1515
</arguments>
1616
</block>
1717
<block class="Magento\Customer\Block\Account\RegisterLink" name="register-link">
@@ -20,11 +20,7 @@
2020
</arguments>
2121
</block>
2222
<block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link"
23-
template="Magento_Customer::account/link/authorization.phtml">
24-
<arguments>
25-
<argument name="sortOrder" xsi:type="number">30</argument>
26-
</arguments>
27-
</block>
23+
template="Magento_Customer::account/link/authorization.phtml"/>
2824
</referenceBlock>
2925
<referenceContainer name="content">
3026
<block class="Magento\Customer\Block\Account\AuthenticationPopup" name="authentication-popup" as="authentication-popup" template="Magento_Customer::account/authentication-popup.phtml">

app/code/Magento/Downloadable/view/frontend/layout/customer_account.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<arguments>
1313
<argument name="path" xsi:type="string">downloadable/customer/products</argument>
1414
<argument name="label" xsi:type="string" translate="true">My Downloadable Products</argument>
15-
<argument name="sortOrder" xsi:type="number">20</argument>
15+
<argument name="sortOrder" xsi:type="number">217</argument>
1616
</arguments>
1717
</block>
1818
</referenceBlock>

app/code/Magento/LoginAsCustomerAssistance/Block/Adminhtml/NotAllowedPopup.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
/**
1515
* Pop-up for Login as Customer button then Login as Customer is not allowed.
16+
*
17+
* @api
1618
*/
1719
class NotAllowedPopup extends Template
1820
{

app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/SaveAssetLinks.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class SaveAssetLinks
2424
private const TABLE_ASSET_KEYWORD = 'media_gallery_asset_keyword';
2525
private const FIELD_ASSET_ID = 'asset_id';
2626
private const FIELD_KEYWORD_ID = 'keyword_id';
27+
private const TABLE_MEDIA_ASSET = 'media_gallery_asset';
2728

2829
/**
2930
* @var ResourceConnection
@@ -73,6 +74,10 @@ public function execute(int $assetId, array $keywordIds): void
7374

7475
$this->deleteAssetKeywords($assetId, $obsoleteKeywordIds);
7576
$this->insertAssetKeywords($assetId, $newKeywordIds);
77+
78+
if ($obsoleteKeywordIds || $newKeywordIds) {
79+
$this->setAssetUpdatedAt($assetId);
80+
}
7681
}
7782

7883
/**
@@ -179,4 +184,28 @@ function (KeywordInterface $keyword): int {
179184
$keywordsData
180185
);
181186
}
187+
188+
/**
189+
* Updates modified date of media asset
190+
*
191+
* @param int $assetId
192+
* @throws CouldNotSaveException
193+
*/
194+
private function setAssetUpdatedAt(int $assetId): void
195+
{
196+
try {
197+
$connection = $this->resourceConnection->getConnection();
198+
$connection->update(
199+
$connection->getTableName(self::TABLE_MEDIA_ASSET),
200+
['updated_at' => null],
201+
['id =?' => $assetId]
202+
);
203+
} catch (\Exception $exception) {
204+
$this->logger->critical($exception);
205+
throw new CouldNotSaveException(
206+
__('Could not update assets modified date'),
207+
$exception
208+
);
209+
}
210+
}
182211
}

app/code/Magento/MediaGallery/Test/Unit/Model/ResourceModel/Keyword/SaveAssetLinksTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testAssetKeywordsSave(int $assetId, array $keywordIds, array $va
7575
$expectedCalls = (int) (count($keywordIds));
7676

7777
if ($expectedCalls) {
78-
$this->resourceConnectionMock->expects($this->once())
78+
$this->resourceConnectionMock->expects($this->exactly(2))
7979
->method('getConnection')
8080
->willReturn($this->connectionMock);
8181
$this->resourceConnectionMock->expects($this->once())

app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Path.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\MediaGalleryCatalogUi\Ui\Component\Listing\Columns;
77

88
use Magento\Catalog\Api\CategoryRepositoryInterface;
9+
use Magento\Catalog\Model\Category;
10+
use Magento\Framework\Exception\NoSuchEntityException;
911
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1012
use Magento\Framework\View\Element\UiComponentFactory;
1113
use Magento\Ui\Component\Listing\Columns\Column;
@@ -63,13 +65,15 @@ public function prepareDataSource(array $dataSource)
6365
* Replace category path ids with category names
6466
*
6567
* @param string $pathWithIds
68+
* @return string
69+
* @throws NoSuchEntityException
6670
*/
6771
private function getCategoryPathWithNames(string $pathWithIds): string
6872
{
6973
$categoryPathWithName = '';
7074
$categoryIds = explode('/', $pathWithIds);
7175
foreach ($categoryIds as $id) {
72-
if ($id == 1) {
76+
if ($id == Category::TREE_ROOT_ID) {
7377
continue;
7478
}
7579
$categoryName = $this->categoryRepository->get($id)->getName();
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\MediaGalleryCatalogUi\Ui\Component\Listing\Filters;
10+
11+
use Magento\Framework\Api\FilterBuilder;
12+
use Magento\Framework\Data\OptionSourceInterface;
13+
use Magento\Framework\View\Element\UiComponent\ContextInterface;
14+
use Magento\Framework\View\Element\UiComponentFactory;
15+
use Magento\Ui\Component\Filters\FilterModifier;
16+
use Magento\Ui\Component\Filters\Type\Select;
17+
use Magento\Ui\Api\BookmarkManagementInterface;
18+
use Magento\Catalog\Api\ProductRepositoryInterface;
19+
20+
/**
21+
* Used in products filter
22+
*/
23+
class UsedInProducts extends Select
24+
{
25+
/**
26+
* @var BookmarkManagementInterface
27+
*/
28+
private $bookmarkManagement;
29+
30+
/**
31+
* @var ProductRepositoryInterface
32+
*/
33+
private $productRepository;
34+
35+
/**
36+
* Constructor
37+
*
38+
* @param ContextInterface $context
39+
* @param UiComponentFactory $uiComponentFactory
40+
* @param FilterBuilder $filterBuilder
41+
* @param FilterModifier $filterModifier
42+
* @param OptionSourceInterface $optionsProvider
43+
* @param BookmarkManagementInterface $bookmarkManagement
44+
* @param ProductRepositoryInterface $productRepository
45+
* @param array $components
46+
* @param array $data
47+
*/
48+
public function __construct(
49+
ContextInterface $context,
50+
UiComponentFactory $uiComponentFactory,
51+
FilterBuilder $filterBuilder,
52+
FilterModifier $filterModifier,
53+
OptionSourceInterface $optionsProvider = null,
54+
BookmarkManagementInterface $bookmarkManagement,
55+
ProductRepositoryInterface $productRepository,
56+
array $components = [],
57+
array $data = []
58+
) {
59+
$this->uiComponentFactory = $uiComponentFactory;
60+
$this->filterBuilder = $filterBuilder;
61+
parent::__construct(
62+
$context,
63+
$uiComponentFactory,
64+
$filterBuilder,
65+
$filterModifier,
66+
$optionsProvider,
67+
$components,
68+
$data
69+
);
70+
$this->bookmarkManagement = $bookmarkManagement;
71+
$this->productRepository = $productRepository;
72+
}
73+
74+
/**
75+
* Prepare component configuration
76+
*
77+
* @return void
78+
*/
79+
public function prepare()
80+
{
81+
$options = [];
82+
$productIds = [];
83+
$bookmarks = $this->bookmarkManagement->loadByNamespace($this->context->getNameSpace())->getItems();
84+
foreach ($bookmarks as $bookmark) {
85+
if ($bookmark->getIdentifier() === 'current') {
86+
$applied = $bookmark->getConfig()['current']['filters']['applied'];
87+
if (isset($applied[$this->getName()])) {
88+
$productIds = $applied[$this->getName()];
89+
}
90+
}
91+
}
92+
93+
foreach ($productIds as $id) {
94+
$product = $this->productRepository->getById($id);
95+
$options[] = [
96+
'value' => $id,
97+
'label' => $product->getName(),
98+
'is_active' => $product->getStatus(),
99+
'path' => $product->getSku(),
100+
'optgroup' => false
101+
102+
];
103+
}
104+
105+
$this->wrappedComponent = $this->uiComponentFactory->create(
106+
$this->getName(),
107+
parent::COMPONENT,
108+
[
109+
'context' => $this->getContext(),
110+
'options' => $options
111+
]
112+
);
113+
114+
$this->wrappedComponent->prepare();
115+
$productsFilterJsConfig = array_replace_recursive(
116+
$this->getJsConfig($this->wrappedComponent),
117+
$this->getJsConfig($this)
118+
);
119+
$this->setData('js_config', $productsFilterJsConfig);
120+
121+
$this->setData(
122+
'config',
123+
array_replace_recursive(
124+
(array)$this->wrappedComponent->getData('config'),
125+
(array)$this->getData('config')
126+
)
127+
);
128+
129+
$this->applyFilter();
130+
131+
parent::prepare();
132+
}
133+
}

app/code/Magento/MediaGalleryCatalogUi/view/adminhtml/ui_component/media_gallery_listing.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
name="product_id"
1414
provider="${ $.parentName }"
1515
sortOrder="110"
16+
class="Magento\MediaGalleryCatalogUi\Ui\Component\Listing\Filters\UsedInProducts"
1617
component="Magento_Catalog/js/components/product-ui-select"
1718
template="ui/grid/filters/elements/ui-select">
1819
<argument name="data" xsi:type="array">

app/code/Magento/MediaGalleryCatalogUi/view/adminhtml/ui_component/standalone_media_gallery_listing.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
name="product_id"
1414
provider="${ $.parentName }"
1515
sortOrder="110"
16+
class="Magento\MediaGalleryCatalogUi\Ui\Component\Listing\Filters\UsedInProducts"
1617
component="Magento_Catalog/js/components/product-ui-select"
1718
template="ui/grid/filters/elements/ui-select">
1819
<argument name="data" xsi:type="array">

0 commit comments

Comments
 (0)