Skip to content

Commit 9e445e7

Browse files
committed
Merge branch '2.4-develop' into L3_PR_21-10-19
2 parents fb704a5 + b2cd0c1 commit 9e445e7

File tree

9 files changed

+177
-29
lines changed

9 files changed

+177
-29
lines changed

app/code/Magento/Catalog/Pricing/Price/TierPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ function (&$priceData) {
177177
/* convert string value to float */
178178
$priceData['price_qty'] *= 1;
179179
if ($this->getConfigTaxDisplayType() === Config::DISPLAY_TYPE_BOTH) {
180-
$exclTaxPrice = $this->calculator->getAmount($priceData['price'], $this->product, true);
180+
$exclTaxPrice = $this->calculator->getAmount($priceData['price'], $this->product);
181181
$priceData['excl_tax_price'] = $exclTaxPrice;
182182
}
183183
$priceData['price'] = $this->applyAdjustment($priceData['price']);

app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@
1111
*/
1212
namespace Magento\Cron\Model\Config\Backend\Product;
1313

14+
use Magento\Framework\Exception\LocalizedException;
15+
1416
/**
1517
* Cron job Alert configuration
1618
*/
1719
class Alert extends \Magento\Framework\App\Config\Value
1820
{
1921
/**
20-
* Cron expression config path
22+
* Cron string path for product alerts
2123
*/
2224
const CRON_STRING_PATH = 'crontab/default/jobs/catalog_product_alert/schedule/cron_expr';
2325

2426
/**
25-
* Cron model config path
27+
* Cron model path for product alerts
2628
*/
2729
const CRON_MODEL_PATH = 'crontab/default/jobs/catalog_product_alert/run/model';
2830

@@ -67,7 +69,7 @@ public function __construct(
6769
* @inheritdoc
6870
*
6971
* @return $this
70-
* @throws \Exception
72+
* @throws LocalizedException
7173
*/
7274
public function afterSave()
7375
{
@@ -83,8 +85,8 @@ public function afterSave()
8385
$frequency = $this->getValue();
8486

8587
$cronExprArray = [
86-
(int)$time[1], //Minute
87-
(int)$time[0], //Hour
88+
(int)($time[1] ?? 0), //Minute
89+
(int)($time[0] ?? 0), //Hour
8890
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_MONTHLY ? '1' : '*', //Day of the Month
8991
'*', //Month of the Year
9092
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_WEEKLY ? '1' : '*', //Day of the Week
@@ -110,8 +112,7 @@ public function afterSave()
110112
self::CRON_MODEL_PATH
111113
)->save();
112114
} catch (\Exception $e) {
113-
// phpcs:ignore Magento2.Exceptions.DirectThrow
114-
throw new \Exception(__('We can\'t save the cron expression.'));
115+
throw new LocalizedException(__('We can\'t save the cron expression.'));
115116
}
116117

117118
return parent::afterSave();

app/code/Magento/Cron/Model/Config/Backend/Sitemap.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
*/
1212
namespace Magento\Cron\Model\Config\Backend;
1313

14+
use Magento\Framework\Exception\LocalizedException;
15+
1416
/**
1517
* Sitemap configuration
1618
*/
1719
class Sitemap extends \Magento\Framework\App\Config\Value
1820
{
1921
/**
20-
* Cron string path
22+
* Cron string path for product alerts
2123
*/
2224
const CRON_STRING_PATH = 'crontab/default/jobs/sitemap_generate/schedule/cron_expr';
2325

@@ -67,16 +69,16 @@ public function __construct(
6769
* After save handler
6870
*
6971
* @return $this
70-
* @throws \Exception
72+
* @throws LocalizedException
7173
*/
7274
public function afterSave()
7375
{
7476
$time = $this->getData('groups/generate/fields/time/value');
7577
$frequency = $this->getData('groups/generate/fields/frequency/value');
7678

7779
$cronExprArray = [
78-
(int)$time[1], //Minute
79-
(int)$time[0], //Hour
80+
(int)($time[1] ?? 0), //Minute
81+
(int)($time[0] ?? 0), //Hour
8082
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_MONTHLY ? '1' : '*', //Day of the Month
8183
'*', //Month of the Year
8284
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_WEEKLY ? '1' : '*', //# Day of the Week
@@ -102,7 +104,7 @@ public function afterSave()
102104
self::CRON_MODEL_PATH
103105
)->save();
104106
} catch (\Exception $e) {
105-
throw new \Exception(__('We can\'t save the cron expression.'));
107+
throw new LocalizedException(__('We can\'t save the cron expression.'));
106108
}
107109
return parent::afterSave();
108110
}

app/code/Magento/MediaGallerySynchronization/Model/FetchMediaStorageFileBatches.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,14 @@ public function execute(): \Traversable
8787
$batch = [];
8888
$mediaDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
8989

90-
/** @var \SplFileInfo $file */
91-
foreach ($this->getAssetsIterator->execute($mediaDirectory->getAbsolutePath()) as $file) {
92-
$relativePath = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA)
93-
->getRelativePath($file->getPathName());
94-
if (!$this->isApplicable($relativePath)) {
90+
foreach ($mediaDirectory->readRecursively($mediaDirectory->getAbsolutePath()) as $file) {
91+
92+
if (!$this->isApplicable($file)) {
9593
continue;
9694
}
9795

98-
$batch[] = $relativePath;
96+
$batch[] = $file;
97+
9998
if (++$i == $this->batchSize) {
10099
yield $batch;
101100
$i = 0;

app/code/Magento/Paypal/view/frontend/web/js/in-context/button.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ define([
2222

2323
this._super();
2424
this.renderPayPalButtons(element);
25-
this.declinePayment = !customer().firstname && !cart().isGuestCheckoutAllowed;
25+
26+
if (cart().isGuestCheckoutAllowed === undefined) {
27+
cart.subscribe(function (updatedCart) {
28+
this.declinePayment = !customer().firstname && !cart().isGuestCheckoutAllowed;
29+
30+
return updatedCart;
31+
}.bind(this));
32+
}
2633

2734
return this;
2835
},
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/** @var $product \Magento\Catalog\Model\Product */
8+
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
9+
$product->isObjectNew(true);
10+
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
11+
->setAttributeSetId(4)
12+
->setName('Simple Product1')
13+
->setSku('simple1')
14+
->setTaxClassId('none')
15+
->setDescription('description uniqueword')
16+
->setShortDescription('short description')
17+
->setOptionsContainer('container1')
18+
->setMsrpDisplayActualPriceType(\Magento\Msrp\Model\Product\Attribute\Source\Type::TYPE_IN_CART)
19+
->setPrice(10)
20+
->setWeight(1)
21+
->setMetaTitle('meta title')
22+
->setMetaKeyword('meta keyword')
23+
->setMetaDescription('meta description')
24+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
25+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
26+
->setWebsiteIds([1])
27+
->setCategoryIds([])
28+
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1])
29+
->setSpecialPrice('5.99')
30+
->save();
31+
32+
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
33+
$product->isObjectNew(true);
34+
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
35+
->setAttributeSetId(4)
36+
->setName('Simple Product2')
37+
->setSku('simple2')
38+
->setTaxClassId('none')
39+
->setDescription('description')
40+
->setShortDescription('short description')
41+
->setOptionsContainer('container1')
42+
->setMsrpDisplayActualPriceType(\Magento\Msrp\Model\Product\Attribute\Source\Type::TYPE_ON_GESTURE)
43+
->setPrice(20)
44+
->setWeight(1)
45+
->setMetaTitle('meta title')
46+
->setMetaKeyword('meta keyword')
47+
->setMetaDescription('meta description')
48+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG)
49+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
50+
->setWebsiteIds([1])
51+
->setCategoryIds([])
52+
->setStockData(['use_config_manage_stock' => 1, 'qty' => 50, 'is_qty_decimal' => 0, 'is_in_stock' => 1])
53+
->setSpecialPrice('15.99')
54+
->save();
55+
56+
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
57+
$product->isObjectNew(true);
58+
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
59+
->setAttributeSetId(4)
60+
->setName('Simple Product3')
61+
->setSku('simple3')
62+
->setTaxClassId('none')
63+
->setDescription('description')
64+
->setShortDescription('short description')
65+
->setPrice(30)
66+
->setWeight(1)
67+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG)
68+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED)
69+
->setWebsiteIds([1])
70+
->setCategoryIds([])
71+
->setStockData(['use_config_manage_stock' => 1, 'qty' => 140, 'is_qty_decimal' => 0, 'is_in_stock' => 1])
72+
->setSpecialPrice('25.99')
73+
->save();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
8+
9+
/** @var \Magento\Framework\Registry $registry */
10+
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
11+
12+
$registry->unregister('isSecureArea');
13+
$registry->register('isSecureArea', true);
14+
15+
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
16+
$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
17+
18+
foreach (['simple1', 'simple2', 'simple3'] as $sku) {
19+
try {
20+
$product = $productRepository->get($sku, false, null, true);
21+
$productRepository->delete($product);
22+
} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
23+
//Product already removed
24+
}
25+
}
26+
27+
$registry->unregister('isSecureArea');
28+
$registry->register('isSecureArea', false);

dev/tests/integration/testsuite/Magento/Setup/Console/Command/DeployStaticContentCommandTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Deploy\Console\DeployStaticOptions;
99
use Magento\Framework\App\DeploymentConfig\FileReader;
1010
use Magento\Framework\App\DeploymentConfig\Writer;
11+
use Magento\Framework\App\DeploymentConfig\Writer\PhpFormatter;
1112
use Magento\Framework\App\Filesystem\DirectoryList;
1213
use Magento\Framework\Config\File\ConfigFilePool;
1314
use Magento\Framework\Console\Cli;
@@ -70,6 +71,11 @@ class DeployStaticContentCommandTest extends \PHPUnit\Framework\TestCase
7071
*/
7172
private $storeManager;
7273

74+
/**
75+
* @var PhpFormatter
76+
*/
77+
private $phpFormatter;
78+
7379
/**
7480
* @inheritdoc
7581
*/
@@ -81,7 +87,7 @@ protected function setUp(): void
8187
$this->filesystem = $this->objectManager->get(Filesystem::class);
8288
$this->configFilePool = $this->objectManager->get(ConfigFilePool::class);
8389
$this->storeManager = $this->objectManager->get(StoreManagerInterface::class);
84-
90+
$this->phpFormatter = $this->objectManager->get(PhpFormatter::class);
8591
$this->config = $this->loadConfig();
8692
$this->envConfig = $this->loadEnvConfig();
8793

@@ -129,10 +135,10 @@ public function testDeployStaticWithoutDbConnection()
129135
);
130136
$this->writer->saveConfig([ConfigFilePool::APP_CONFIG => $newData], true);
131137

132-
// remove application environment config for emulate work without db
138+
// rewrite application environment config with only remote storage details to emulate work without db
133139
$this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->writeFile(
134140
$this->configFilePool->getPath(ConfigFilePool::APP_ENV),
135-
"<?php\n return [];\n"
141+
$this->phpFormatter->format(['remote_storage' => $this->envConfig['remote_storage']])
136142
);
137143
$this->storeManager->reinitStores();
138144

lib/internal/Magento/Framework/View/Element/BlockFactory.php

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Framework\View\Element;
77

88
use Magento\Framework\ObjectManagerInterface;
9+
use Magento\Framework\ObjectManager\ConfigInterface;
10+
use Magento\Framework\App\ObjectManager;
911

1012
/**
1113
* Creates Blocks
@@ -16,20 +18,29 @@
1618
class BlockFactory
1719
{
1820
/**
19-
* Object manager
20-
*
2121
* @var ObjectManagerInterface
2222
*/
2323
protected $objectManager;
2424

25+
/**
26+
* Object manager config
27+
*
28+
* @var ConfigInterface
29+
*/
30+
private $config;
31+
2532
/**
2633
* Constructor
2734
*
2835
* @param ObjectManagerInterface $objectManager
36+
* @param ConfigInterface $config
2937
*/
30-
public function __construct(ObjectManagerInterface $objectManager)
31-
{
38+
public function __construct(
39+
ObjectManagerInterface $objectManager,
40+
?ConfigInterface $config = null
41+
) {
3242
$this->objectManager = $objectManager;
43+
$this->config = $config ?: ObjectManager::getInstance()->get(ConfigInterface::class);
3344
}
3445

3546
/**
@@ -42,8 +53,9 @@ public function __construct(ObjectManagerInterface $objectManager)
4253
*/
4354
public function createBlock($blockName, array $arguments = [])
4455
{
45-
$blockName = ltrim($blockName, '\\');
46-
$block = $this->objectManager->create($blockName, $arguments);
56+
$blockName = ltrim($blockName, '\\');
57+
$arguments = $this->getConfigArguments($blockName, $arguments);
58+
$block = $this->objectManager->create($blockName, $arguments);
4759
if (!$block instanceof BlockInterface) {
4860
throw new \LogicException($blockName . ' does not implement BlockInterface');
4961
}
@@ -52,4 +64,24 @@ public function createBlock($blockName, array $arguments = [])
5264
}
5365
return $block;
5466
}
67+
68+
/**
69+
* Get All Config Arguments based on Block Name
70+
*
71+
* @param string $blockName
72+
* @param array $arguments
73+
* @return array $arguments
74+
*/
75+
private function getConfigArguments($blockName, array $arguments = [])
76+
{
77+
if (!$this->config) {
78+
return $arguments;
79+
}
80+
$configArguments = $this->config->getArguments($blockName);
81+
if ($configArguments && isset($configArguments['data'])) {
82+
$arguments['data'] = ($arguments && isset($arguments['data'])) ?
83+
array_merge($arguments['data'], $configArguments['data']) : $configArguments['data'];
84+
}
85+
return $arguments;
86+
}
5587
}

0 commit comments

Comments
 (0)