Skip to content

Commit 8eead95

Browse files
author
Gabriel da Gama
authored
Merge branch '2.4-develop' into feature/fix_24091_configurable_product_options_on_wishlist
2 parents ac6be80 + d31cd74 commit 8eead95

File tree

283 files changed

+8449
-1401
lines changed

Some content is hidden

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

283 files changed

+8449
-1401
lines changed

app/code/Magento/Analytics/Model/ReportUrlProvider.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ class ReportUrlProvider
4747
*/
4848
private $urlReportConfigPath = 'analytics/url/report';
4949

50+
/**
51+
* Path to Advanced Reporting documentation URL.
52+
*
53+
* @var string
54+
*/
55+
private $urlReportDocConfigPath = 'analytics/url/documentation';
56+
5057
/**
5158
* @param AnalyticsToken $analyticsToken
5259
* @param OTPRequest $otpRequest
@@ -80,13 +87,15 @@ public function getUrl()
8087
));
8188
}
8289

83-
$url = $this->config->getValue($this->urlReportConfigPath);
8490
if ($this->analyticsToken->isTokenExist()) {
91+
$url = $this->config->getValue($this->urlReportConfigPath);
8592
$otp = $this->otpRequest->call();
8693
if ($otp) {
8794
$query = http_build_query(['otp' => $otp], '', '&');
8895
$url .= '?' . $query;
8996
}
97+
} else {
98+
$url = $this->config->getValue($this->urlReportDocConfigPath);
9099
}
91100

92101
return $url;

app/code/Magento/Analytics/Test/Mftf/ActionGroup/AssertAdminAdvancedReportingPageUrlActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515

1616
<switchToNextTab stepKey="switchToNewTab"/>
1717
<waitForPageLoad stepKey="waitForAdvancedReportingPageLoad"/>
18-
<seeInCurrentUrl url="advancedreporting.rjmetrics.com/report" stepKey="seeAssertAdvancedReportingPageUrl"/>
18+
<seeInCurrentUrl url="reports/advanced-reporting" stepKey="seeAssertAdvancedReportingPageUrl"/>
1919
</actionGroup>
2020
</actionGroups>

app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,10 @@ class ReportUrlProviderTest extends TestCase
4343
*/
4444
private $flagManagerMock;
4545

46-
/**
47-
* @var ObjectManagerHelper
48-
*/
49-
private $objectManagerHelper;
50-
5146
/**
5247
* @var ReportUrlProvider
5348
*/
54-
private $reportUrlProvider;
55-
56-
/**
57-
* @var string
58-
*/
59-
private $urlReportConfigPath = 'path/url/report';
49+
private $model;
6050

6151
/**
6252
* @return void
@@ -71,35 +61,36 @@ protected function setUp(): void
7161

7262
$this->flagManagerMock = $this->createMock(FlagManager::class);
7363

74-
$this->objectManagerHelper = new ObjectManagerHelper($this);
64+
$objectManagerHelper = new ObjectManagerHelper($this);
7565

76-
$this->reportUrlProvider = $this->objectManagerHelper->getObject(
66+
$this->model = $objectManagerHelper->getObject(
7767
ReportUrlProvider::class,
7868
[
7969
'config' => $this->configMock,
8070
'analyticsToken' => $this->analyticsTokenMock,
8171
'otpRequest' => $this->otpRequestMock,
8272
'flagManager' => $this->flagManagerMock,
83-
'urlReportConfigPath' => $this->urlReportConfigPath,
8473
]
8574
);
8675
}
8776

8877
/**
8978
* @param bool $isTokenExist
9079
* @param string|null $otp If null OTP was not received.
80+
* @param string $configPath
81+
* @return void
9182
*
9283
* @dataProvider getUrlDataProvider
9384
*/
94-
public function testGetUrl($isTokenExist, $otp)
85+
public function testGetUrl(bool $isTokenExist, ?string $otp, string $configPath): void
9586
{
9687
$reportUrl = 'https://example.com/report';
9788
$url = '';
9889

9990
$this->configMock
10091
->expects($this->once())
10192
->method('getValue')
102-
->with($this->urlReportConfigPath)
93+
->with($configPath)
10394
->willReturn($reportUrl);
10495
$this->analyticsTokenMock
10596
->expects($this->once())
@@ -114,18 +105,19 @@ public function testGetUrl($isTokenExist, $otp)
114105
if ($isTokenExist && $otp) {
115106
$url = $reportUrl . '?' . http_build_query(['otp' => $otp], '', '&');
116107
}
117-
$this->assertSame($url ?: $reportUrl, $this->reportUrlProvider->getUrl());
108+
109+
$this->assertSame($url ?: $reportUrl, $this->model->getUrl());
118110
}
119111

120112
/**
121113
* @return array
122114
*/
123-
public function getUrlDataProvider()
115+
public function getUrlDataProvider(): array
124116
{
125117
return [
126-
'TokenDoesNotExist' => [false, null],
127-
'TokenExistAndOtpEmpty' => [true, null],
128-
'TokenExistAndOtpValid' => [true, '249e6b658877bde2a77bc4ab'],
118+
'TokenDoesNotExist' => [false, null, 'analytics/url/documentation'],
119+
'TokenExistAndOtpEmpty' => [true, null, 'analytics/url/report'],
120+
'TokenExistAndOtpValid' => [true, '249e6b658877bde2a77bc4ab', 'analytics/url/report'],
129121
];
130122
}
131123

@@ -140,6 +132,6 @@ public function testGetUrlWhenSubscriptionUpdateRunning()
140132
->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)
141133
->willReturn('http://store.com');
142134
$this->expectException(SubscriptionUpdateException::class);
143-
$this->reportUrlProvider->getUrl();
135+
$this->model->getUrl();
144136
}
145137
}

app/code/Magento/Analytics/etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<otp>https://advancedreporting.rjmetrics.com/otp</otp>
1616
<report>https://advancedreporting.rjmetrics.com/report</report>
1717
<notify_data_changed>https://advancedreporting.rjmetrics.com/report</notify_data_changed>
18+
<documentation>https://docs.magento.com/user-guide/reports/advanced-reporting.html</documentation>
1819
</url>
1920
<integration_name>Magento Analytics user</integration_name>
2021
<general>

app/code/Magento/Backend/view/adminhtml/layout/default.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<body>
1818
<attribute name="id" value="html-body"/>
1919
<block name="require.js" class="Magento\Backend\Block\Page\RequireJs" template="Magento_Backend::page/js/require_js.phtml"/>
20+
<block class="Magento\Framework\View\Element\Template" name="head.additional" template="Magento_Backend::page/container.phtml"/>
2021
<referenceContainer name="global.notices">
2122
<block class="Magento\Backend\Block\Page\Notices" name="global_notices" as="global_notices" template="Magento_Backend::page/notices.phtml"/>
2223
</referenceContainer>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
?>
7+
<?= $block->getChildHtml(); ?>

app/code/Magento/Bundle/view/adminhtml/ui_component/bundle_product_listing.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<label translate="true">Status</label>
5959
<dataScope>status</dataScope>
6060
<imports>
61-
<link name="visible">componentType = column, index = ${ $.index }:visible</link>
61+
<link name="visible">ns = ${ $.ns }, index = ${ $.index }:visible</link>
6262
</imports>
6363
</settings>
6464
</filterSelect>

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Catalog\Controller\Adminhtml\Product\Initialization;
88

99
use Magento\Backend\Helper\Js;
10+
use Magento\Catalog\Api\Data\CategoryLinkInterfaceFactory;
1011
use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory as CustomOptionFactory;
1112
use Magento\Catalog\Api\Data\ProductLinkInterfaceFactory as ProductLinkFactory;
1213
use Magento\Catalog\Api\Data\ProductLinkTypeInterface;
@@ -115,6 +116,11 @@ class Helper
115116
*/
116117
private $dateTimeFilter;
117118

119+
/**
120+
* @var CategoryLinkInterfaceFactory
121+
*/
122+
private $categoryLinkFactory;
123+
118124
/**
119125
* Constructor
120126
*
@@ -132,6 +138,7 @@ class Helper
132138
* @param FormatInterface|null $localeFormat
133139
* @param ProductAuthorization|null $productAuthorization
134140
* @param DateTimeFilter|null $dateTimeFilter
141+
* @param CategoryLinkInterfaceFactory|null $categoryLinkFactory
135142
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
136143
*/
137144
public function __construct(
@@ -148,7 +155,8 @@ public function __construct(
148155
AttributeFilter $attributeFilter = null,
149156
FormatInterface $localeFormat = null,
150157
?ProductAuthorization $productAuthorization = null,
151-
?DateTimeFilter $dateTimeFilter = null
158+
?DateTimeFilter $dateTimeFilter = null,
159+
?CategoryLinkInterfaceFactory $categoryLinkFactory = null
152160
) {
153161
$this->request = $request;
154162
$this->storeManager = $storeManager;
@@ -166,6 +174,7 @@ public function __construct(
166174
$this->localeFormat = $localeFormat ?: $objectManager->get(FormatInterface::class);
167175
$this->productAuthorization = $productAuthorization ?? $objectManager->get(ProductAuthorization::class);
168176
$this->dateTimeFilter = $dateTimeFilter ?? $objectManager->get(DateTimeFilter::class);
177+
$this->categoryLinkFactory = $categoryLinkFactory ?? $objectManager->get(CategoryLinkInterfaceFactory::class);
169178
}
170179

171180
/**
@@ -238,6 +247,7 @@ public function initializeFromData(Product $product, array $productData)
238247

239248
$product = $this->setProductLinks($product);
240249
$product = $this->fillProductOptions($product, $productOptions);
250+
$this->setCategoryLinks($product);
241251

242252
$product->setCanSaveCustomOptions(
243253
!empty($productData['affect_product_custom_options']) && !$product->getOptionsReadonly()
@@ -484,4 +494,30 @@ function ($valueData) {
484494

485495
return $product->setOptions($customOptions);
486496
}
497+
498+
/**
499+
* Set category links based on initialized category ids
500+
*
501+
* @param Product $product
502+
*/
503+
private function setCategoryLinks(Product $product): void
504+
{
505+
$extensionAttributes = $product->getExtensionAttributes();
506+
$categoryLinks = [];
507+
foreach ((array) $extensionAttributes->getCategoryLinks() as $categoryLink) {
508+
$categoryLinks[$categoryLink->getCategoryId()] = $categoryLink;
509+
}
510+
511+
$newCategoryLinks = [];
512+
foreach ($product->getCategoryIds() as $categoryId) {
513+
$categoryLink = $categoryLinks[$categoryId] ??
514+
$this->categoryLinkFactory->create()
515+
->setCategoryId($categoryId)
516+
->setPosition(0);
517+
$newCategoryLinks[] = $categoryLink;
518+
}
519+
520+
$extensionAttributes->setCategoryLinks(!empty($newCategoryLinks) ? $newCategoryLinks : null);
521+
$product->setExtensionAttributes($extensionAttributes);
522+
}
487523
}

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
use Magento\Framework\App\Request\DataPersistorInterface;
1616

1717
/**
18-
* Class Save
18+
* Product save controller
19+
*
1920
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2021
*/
2122
class Save extends \Magento\Catalog\Controller\Adminhtml\Product implements HttpPostActionInterface
@@ -141,10 +142,6 @@ public function execute()
141142
$canSaveCustomOptions = $product->getCanSaveCustomOptions();
142143
$product->save();
143144
$this->handleImageRemoveError($data, $product->getId());
144-
$this->categoryLinkManagement->assignProductToCategories(
145-
$product->getSku(),
146-
$product->getCategoryIds()
147-
);
148145
$productId = $product->getEntityId();
149146
$productAttributeSetId = $product->getAttributeSetId();
150147
$productTypeId = $product->getTypeId();

0 commit comments

Comments
 (0)