Skip to content

Commit ca33ddc

Browse files
Merge pull request #150 from magento-commerce/1.1.45-release
1.1.45 Release
2 parents 07928a1 + ad2cd30 commit ca33ddc

14 files changed

+1385
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magento/quality-patches",
33
"description": "Provides quality patches for AdobeCommerce & Magento OpenSource",
44
"type": "magento2-component",
5-
"version": "1.1.44",
5+
"version": "1.1.45",
66
"license": "proprietary",
77
"repositories": {
88
"repo": {

patches-info.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
diff --git a/vendor/magento/module-company-payment/Plugin/Payment/Model/MethodInterfacePlugin.php b/vendor/magento/module-company-payment/Plugin/Payment/Model/MethodInterfacePlugin.php
2+
new file mode 100644
3+
index 000000000000..c18f876f0d5c
4+
--- /dev/null
5+
+++ b/vendor/magento/module-company-payment/Plugin/Payment/Model/MethodInterfacePlugin.php
6+
@@ -0,0 +1,86 @@
7+
+<?php
8+
+/************************************************************************
9+
+ *
10+
+ * ADOBE CONFIDENTIAL
11+
+ * ___________________
12+
+ *
13+
+ * Copyright 2023 Adobe
14+
+ * All Rights Reserved.
15+
+ *
16+
+ * NOTICE: All information contained herein is, and remains
17+
+ * the property of Adobe and its suppliers, if any. The intellectual
18+
+ * and technical concepts contained herein are proprietary to Adobe
19+
+ * and its suppliers and are protected by all applicable intellectual
20+
+ * property laws, including trade secret and copyright laws.
21+
+ * Dissemination of this information or reproduction of this material
22+
+ * is strictly forbidden unless prior written permission is obtained
23+
+ * from Adobe.
24+
+ * ************************************************************************
25+
+ */
26+
+declare(strict_types=1);
27+
+
28+
+namespace Magento\CompanyPayment\Plugin\Payment\Model;
29+
+
30+
+use Magento\Authorization\Model\UserContextInterface;
31+
+use Magento\Company\Model\CompanyManagement;
32+
+use Magento\CompanyPayment\Model\Payment\AvailabilityChecker;
33+
+use Magento\Payment\Model\MethodInterface;
34+
+
35+
+/**
36+
+ * Plugin for check payment method is allowed on company level
37+
+ */
38+
+class MethodInterfacePlugin
39+
+{
40+
+ /**
41+
+ * @var UserContextInterface
42+
+ */
43+
+ private $userContext;
44+
+
45+
+ /**
46+
+ * @var CompanyManagement
47+
+ */
48+
+ private $companyManagement;
49+
+
50+
+ /**
51+
+ * @var AvailabilityChecker
52+
+ */
53+
+ private $availabilityChecker;
54+
+
55+
+ /**
56+
+ * @param UserContextInterface $userContext
57+
+ * @param CompanyManagement $companyManagement
58+
+ * @param AvailabilityChecker $availabilityChecker
59+
+ */
60+
+ public function __construct(
61+
+ UserContextInterface $userContext,
62+
+ CompanyManagement $companyManagement,
63+
+ AvailabilityChecker $availabilityChecker,
64+
+ ) {
65+
+ $this->userContext = $userContext;
66+
+ $this->companyManagement = $companyManagement;
67+
+ $this->availabilityChecker = $availabilityChecker;
68+
+ }
69+
+
70+
+ /**
71+
+ * Checking if payment is available on company level
72+
+ *
73+
+ * @param MethodInterface $subject
74+
+ * @param bool $result
75+
+ * @return bool
76+
+ */
77+
+ public function afterIsAvailable(MethodInterface $subject, bool $result): bool
78+
+ {
79+
+ $customerId = $this->userContext->getUserId();
80+
+ if ($customerId) {
81+
+ $company = $this->companyManagement->getByCustomerId($customerId);
82+
+ if ($company) {
83+
+ $paymentMethodCode = $subject->getCode();
84+
+ $isAvailable = $this->availabilityChecker->isAvailableForCompany($paymentMethodCode, $company);
85+
+ if (!$isAvailable) {
86+
+ return false;
87+
+ }
88+
+ }
89+
+ }
90+
+ return $result;
91+
+ }
92+
+}
93+
diff --git a/vendor/magento/module-company-payment/Plugin/Paypal/Block/Express/InContext/SmartButtonPlugin.php b/vendor/magento/module-company-payment/Plugin/Paypal/Block/Express/InContext/SmartButtonPlugin.php
94+
new file mode 100644
95+
index 000000000000..836b4a5100e4
96+
--- /dev/null
97+
+++ b/vendor/magento/module-company-payment/Plugin/Paypal/Block/Express/InContext/SmartButtonPlugin.php
98+
@@ -0,0 +1,86 @@
99+
+<?php
100+
+/************************************************************************
101+
+ *
102+
+ * ADOBE CONFIDENTIAL
103+
+ * ___________________
104+
+ *
105+
+ * Copyright 2023 Adobe
106+
+ * All Rights Reserved.
107+
+ *
108+
+ * NOTICE: All information contained herein is, and remains
109+
+ * the property of Adobe and its suppliers, if any. The intellectual
110+
+ * and technical concepts contained herein are proprietary to Adobe
111+
+ * and its suppliers and are protected by all applicable intellectual
112+
+ * property laws, including trade secret and copyright laws.
113+
+ * Dissemination of this information or reproduction of this material
114+
+ * is strictly forbidden unless prior written permission is obtained
115+
+ * from Adobe.
116+
+ * ************************************************************************
117+
+ */
118+
+declare(strict_types=1);
119+
+
120+
+namespace Magento\CompanyPayment\Plugin\Paypal\Block\Express\InContext;
121+
+
122+
+use Magento\Authorization\Model\UserContextInterface;
123+
+use Magento\Company\Model\CompanyManagement;
124+
+use Magento\CompanyPayment\Model\Payment\AvailabilityChecker;
125+
+use Magento\Paypal\Block\Express\InContext\SmartButton;
126+
+use Magento\Paypal\Model\Config;
127+
+
128+
+/**
129+
+ * Plugin for check PayPal express smart button is allowed on company level
130+
+ */
131+
+class SmartButtonPlugin
132+
+{
133+
+ /**
134+
+ * @var UserContextInterface
135+
+ */
136+
+ private $userContext;
137+
+
138+
+ /**
139+
+ * @var CompanyManagement
140+
+ */
141+
+ private $companyManagement;
142+
+
143+
+ /**
144+
+ * @var AvailabilityChecker
145+
+ */
146+
+ private $availabilityChecker;
147+
+
148+
+ /**
149+
+ * @param UserContextInterface $userContext
150+
+ * @param CompanyManagement $companyManagement
151+
+ * @param AvailabilityChecker $availabilityChecker
152+
+ */
153+
+ public function __construct(
154+
+ UserContextInterface $userContext,
155+
+ CompanyManagement $companyManagement,
156+
+ AvailabilityChecker $availabilityChecker,
157+
+ ) {
158+
+ $this->userContext = $userContext;
159+
+ $this->companyManagement = $companyManagement;
160+
+ $this->availabilityChecker = $availabilityChecker;
161+
+ }
162+
+
163+
+ /**
164+
+ * Checking if PayPal express smart button is available on company level
165+
+ *
166+
+ * @param SmartButton $subject
167+
+ * @param string $result
168+
+ * @return string
169+
+ */
170+
+ public function afterToHtml(SmartButton $subject, string $result): string
171+
+ {
172+
+ $customerId = $this->userContext->getUserId();
173+
+ if ($customerId) {
174+
+ $company = $this->companyManagement->getByCustomerId($customerId);
175+
+ if ($company) {
176+
+ $isAvailable = $this->availabilityChecker->isAvailableForCompany(Config::METHOD_EXPRESS, $company);
177+
+ if (!$isAvailable) {
178+
+ return '';
179+
+ }
180+
+ }
181+
+ }
182+
+ return $result;
183+
+ }
184+
+}
185+
diff --git a/vendor/magento/module-company-payment/etc/frontend/di.xml b/vendor/magento/module-company-payment/etc/frontend/di.xml
186+
index 5cd9933f8a44..978a1db5f31a 100644
187+
--- a/vendor/magento/module-company-payment/etc/frontend/di.xml
188+
+++ b/vendor/magento/module-company-payment/etc/frontend/di.xml
189+
@@ -12,4 +12,10 @@
190+
<type name="Magento\Checkout\Block\Checkout\LayoutProcessor">
191+
<plugin name="company_customerbalance_allowed_on_checkout" type="Magento\CompanyPayment\Plugin\Checkout\Block\LayoutProcessorPlugin"/>
192+
</type>
193+
+ <type name="Magento\Payment\Model\MethodInterface">
194+
+ <plugin name="check_paymentmethod_is_allowed_on_company_level" type="Magento\CompanyPayment\Plugin\Payment\Model\MethodInterfacePlugin"/>
195+
+ </type>
196+
+ <type name="Magento\Paypal\Block\Express\InContext\SmartButton">
197+
+ <plugin name="check_smartbutton_is_allowed_on_company_level" type="Magento\CompanyPayment\Plugin\Paypal\Block\Express\InContext\SmartButtonPlugin"/>
198+
+ </type>
199+
</config>
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
diff --git a/vendor/magento/module-visual-merchandiser/Block/Adminhtml/Category/Merchandiser.php b/vendor/magento/module-visual-merchandiser/Block/Adminhtml/Category/Merchandiser.php
2+
index 5203bf246c8..1d34f5aedc1 100644
3+
--- a/vendor/magento/module-visual-merchandiser/Block/Adminhtml/Category/Merchandiser.php
4+
+++ b/vendor/magento/module-visual-merchandiser/Block/Adminhtml/Category/Merchandiser.php
5+
@@ -7,6 +7,7 @@ namespace Magento\VisualMerchandiser\Block\Adminhtml\Category;
6+
7+
use Magento\Backend\Block\Template;
8+
use Magento\Backend\Block\Widget\Context;
9+
+use Magento\Framework\Exception\NoSuchEntityException;
10+
use Magento\Framework\Registry;
11+
use Magento\VisualMerchandiser\Model\Position\Cache;
12+
13+
@@ -49,6 +50,7 @@ class Merchandiser extends Template
14+
* Get dialog URL
15+
*
16+
* @return string
17+
+ * @throws NoSuchEntityException
18+
* @since 100.1.0
19+
*/
20+
public function getDialogUrl()
21+
@@ -58,7 +60,8 @@ class Merchandiser extends Template
22+
[
23+
'cache_key' => $this->getPositionCacheKey(),
24+
'componentJson' => true,
25+
- 'category_id' => $this->getCategoryId()
26+
+ 'category_id' => $this->getCategoryId(),
27+
+ 'store_id' => $this->getStoreId()
28+
]
29+
);
30+
}
31+
@@ -96,6 +99,17 @@ class Merchandiser extends Template
32+
return $this->getRequest()->getParam('id');
33+
}
34+
35+
+ /**
36+
+ * Retrieve current store id
37+
+ *
38+
+ * @return int
39+
+ * @throws NoSuchEntityException
40+
+ */
41+
+ private function getStoreId(): int
42+
+ {
43+
+ return $this->_storeManager->getStore()->getId();
44+
+ }
45+
+
46+
/**
47+
* Get position cache key
48+
*
49+
diff --git a/vendor/magento/module-visual-merchandiser/Model/Category/Products.php b/vendor/magento/module-visual-merchandiser/Model/Category/Products.php
50+
index 8a809eaae39..d2fcb04e8b3 100644
51+
--- a/vendor/magento/module-visual-merchandiser/Model/Category/Products.php
52+
+++ b/vendor/magento/module-visual-merchandiser/Model/Category/Products.php
53+
@@ -146,6 +146,9 @@ class Products
54+
'small_image'
55+
]
56+
);
57+
+ if ($store !== null) {
58+
+ $collection->setStoreId((int)$store);
59+
+ }
60+
61+
$collection = $this->quantityStockResolver->joinStock($collection);
62+
63+
diff --git a/vendor/magento/module-visual-merchandiser/Model/Product/DataProvider.php b/vendor/magento/module-visual-merchandiser/Model/Product/DataProvider.php
64+
index e403151caa2..55f9b921877 100755
65+
--- a/vendor/magento/module-visual-merchandiser/Model/Product/DataProvider.php
66+
+++ b/vendor/magento/module-visual-merchandiser/Model/Product/DataProvider.php
67+
@@ -12,9 +12,9 @@ use Magento\Framework\Api\Filter;
68+
use Magento\Framework\App\ObjectManager;
69+
use Magento\Framework\App\RequestInterface;
70+
use Magento\Framework\Exception\LocalizedException;
71+
-use Magento\Store\Model\Store;
72+
use Magento\Ui\DataProvider\AbstractDataProvider;
73+
use Magento\VisualMerchandiser\Model\Position\Cache;
74+
+use Magento\VisualMerchandiser\Model\Resolver\QuantityAndStock;
75+
76+
/**
77+
* Class DataProvider for the Visual Merchandiser product selection grid
78+
@@ -46,6 +46,12 @@ class DataProvider extends AbstractDataProvider
79+
*/
80+
private $positionResolver;
81+
82+
+ /**
83+
+ * @var QuantityAndStock|mixed
84+
+ */
85+
+ private QuantityAndStock $quantityAndStock;
86+
+
87+
+
88+
/**
89+
* @param string $name
90+
* @param string $primaryFieldName
91+
@@ -56,7 +62,9 @@ class DataProvider extends AbstractDataProvider
92+
* @param array $meta
93+
* @param array $data
94+
* @param PositionResolver|null $positionResolver
95+
+ * @param QuantityAndStock|null $quantityAndStock
96+
* @throws LocalizedException
97+
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
98+
*/
99+
public function __construct(
100+
$name,
101+
@@ -67,13 +75,15 @@ class DataProvider extends AbstractDataProvider
102+
Cache $cache,
103+
array $meta = [],
104+
array $data = [],
105+
- ?PositionResolver $positionResolver = null
106+
+ ?PositionResolver $positionResolver = null,
107+
+ ?QuantityAndStock $quantityAndStock = null
108+
) {
109+
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
110+
111+
$this->request = $request;
112+
$this->cache = $cache;
113+
$this->positionResolver = $positionResolver ?: ObjectManager::getInstance()->get(PositionResolver::class);
114+
+ $this->quantityAndStock = $quantityAndStock ?: ObjectManager::getInstance()->get(QuantityAndStock::class);
115+
116+
$this->collection = $collectionFactory->create()->addAttributeToSelect(
117+
'sku'
118+
@@ -87,14 +97,9 @@ class DataProvider extends AbstractDataProvider
119+
'price'
120+
);
121+
122+
- $this->collection->joinField(
123+
- 'qty',
124+
- 'cataloginventory_stock_item',
125+
- 'qty',
126+
- 'product_id=entity_id',
127+
- '{{table}}.stock_id=1',
128+
- 'left'
129+
- );
130+
+ $this->collection->setStoreId($this->request->getParam('store_id', "0"));
131+
+ $this->collection = $this->quantityAndStock->joinStock($this->collection);
132+
+ $this->collection->getSelect()->group('e.entity_id');
133+
134+
$this->prepareUpdateUrl();
135+
}
136+
@@ -139,6 +144,8 @@ class DataProvider extends AbstractDataProvider
137+
$this->positionCacheKey = $paramValue;
138+
} elseif ('%category_id%' === $paramValue) {
139+
$paramValue = $this->request->getParam($paramName);
140+
+ } elseif ('%store_id%' === $paramValue) {
141+
+ $paramValue = $this->request->getParam($paramName, "0");
142+
}
143+
144+
if ($paramValue) {
145+
@@ -192,23 +199,25 @@ class DataProvider extends AbstractDataProvider
146+
*/
147+
public function getData()
148+
{
149+
- $this->collection->setStoreId(Store::DEFAULT_STORE_ID);
150+
$this->collection->getLimitationFilters()->setUsePriceIndex(false);
151+
$this->addPositionData();
152+
$positions = $this->cache->getPositions($this->positionCacheKey);
153+
$categoryId = $this->request->getParam('category_id');
154+
$arrItems = [];
155+
- $arrItems['totalRecords'] = $this->collection->getSize();
156+
+ $arrItems['totalRecords'] = count($this->collection->getItems());
157+
$arrItems['items'] = [];
158+
+ $arrItems['allIds'] = [];
159+
if ($positions === false && $categoryId !== null) {
160+
$arrItems['selectedData'] = $this->positionResolver->getPositions((int) $categoryId);
161+
} else {
162+
$arrItems['selectedData'] = $positions;
163+
}
164+
- $arrItems['allIds'] = $this->collection->getAllIds();
165+
166+
foreach ($this->collection->getItems() as $item) {
167+
- $arrItems['items'][] = $item->toArray();
168+
+ $itemDetails = $item->toArray();
169+
+ $itemDetails['qty'] = $itemDetails['stock'] ?? 0;
170+
+ $arrItems['items'][] = $itemDetails;
171+
+ $arrItems['allIds'][] = $item->getId();
172+
}
173+
174+
return $arrItems;
175+
diff --git a/vendor/magento/module-visual-merchandiser/view/adminhtml/ui_component/merchandiser_product_listing.xml b/vendor/magento/module-visual-merchandiser/view/adminhtml/ui_component/merchandiser_product_listing.xml
176+
index 848bf1f059d..d3c3b9c5147 100755
177+
--- a/vendor/magento/module-visual-merchandiser/view/adminhtml/ui_component/merchandiser_product_listing.xml
178+
+++ b/vendor/magento/module-visual-merchandiser/view/adminhtml/ui_component/merchandiser_product_listing.xml
179+
@@ -23,6 +23,7 @@
180+
<filterUrlParams>
181+
<param name="cache_key">*</param>
182+
<param name="category_id">%category_id%</param>
183+
+ <param name="store_id">%store_id%</param>
184+
</filterUrlParams>
185+
<updateUrl path="mui/index/render"/>
186+
</settings>

0 commit comments

Comments
 (0)