Skip to content

Commit

Permalink
Merge pull request #1 from magento/2.4-develop
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
nikolalardev authored Dec 3, 2020
2 parents 26acabe + f6c4e1c commit d21a4fd
Show file tree
Hide file tree
Showing 300 changed files with 6,988 additions and 1,227 deletions.
7 changes: 7 additions & 0 deletions app/code/Magento/Analytics/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,12 @@
<token/>
</general>
</analytics>
<system>
<media_storage_configuration>
<allowed_resources>
<analytics_folder>analytics</analytics_folder>
</allowed_resources>
</media_storage_configuration>
</system>
</default>
</config>
32 changes: 9 additions & 23 deletions app/code/Magento/Authorization/Model/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,30 @@
class Rules extends \Magento\Framework\Model\AbstractModel
{
/**
* Class constructor
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Authorization\Model\ResourceModel\Rules $resource
* @param \Magento\Authorization\Model\ResourceModel\Rules\Collection $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Authorization\Model\ResourceModel\Rules $resource,
\Magento\Authorization\Model\ResourceModel\Rules\Collection $resourceCollection,
array $data = []
) {
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}

/**
* Class constructor
*
* @return void
* @inheritdoc
*/
protected function _construct()
{
$this->_init(\Magento\Authorization\Model\ResourceModel\Rules::class);
}

/**
* Obsolete method of update
*
* @return $this
* @deprecated Method was never implemented and used.
*/
public function update()
{
$this->getResource()->update($this);
// phpcs:disable Magento2.Functions.DiscouragedFunction
trigger_error('Method was never implemented and used.', E_USER_DEPRECATED);

return $this;
}

/**
* Save authorization rule relation
*
* @return $this
*/
public function saveRel()
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/AwsS3/Driver/AwsS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ public function getAbsolutePath($basePath, $path, $scheme = null)
* Resolves relative path.
*
* @param string $path Absolute path
* @param bool $fixPath
* @return string Relative path
*/
private function normalizeRelativePath(string $path, bool $fixPath = false): string
Expand Down Expand Up @@ -358,7 +359,7 @@ public function isFile($path): bool
return false;
}

$path = $this->normalizeRelativePath($path, true);;
$path = $this->normalizeRelativePath($path, true);

if ($this->adapter->has($path) && ($meta = $this->adapter->getMetadata($path))) {
return ($meta['type'] ?? null) === self::TYPE_FILE;
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/AwsS3/Driver/AwsS3Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public function createConfigured(
throw new DriverException(__('Bucket and region are required values'));
}

if (!empty($config['http_handler'])) {
$config['http_handler'] = $this->objectManager->create($config['http_handler'])($config);
}

$client = new S3Client($config);
$adapter = new AwsS3Adapter($client, $config['bucket'], $prefix);

Expand Down
61 changes: 61 additions & 0 deletions app/code/Magento/AwsS3/Model/HttpLoggerHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\AwsS3\Model;

use Aws\Handler\GuzzleV6\GuzzleHandler;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\MessageFormatter;
use GuzzleHttp\Middleware;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;

final class HttpLoggerHandler
{
/**
* @var Filesystem\Directory\WriteInterface
*/
private $directory;

/**
* @var string
*/
private $file;

/**
* @param Filesystem $filesystem
* @param string $file
* @throws FileSystemException
*/
public function __construct(
Filesystem $filesystem,
$file = 'debug/s3.log'
) {
$this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
$this->file = $file;
}

public function __invoke()
{
$this->directory->create(pathinfo($this->file, PATHINFO_DIRNAME));
$localStream = $this->directory->getDriver()->fileOpen($this->directory->getAbsolutePath($this->file), 'a');
$streamHandler = new StreamHandler($localStream, Logger::DEBUG, true, null, true);
$logger = new \Monolog\Logger('S3', [$streamHandler]);
$stack = HandlerStack::create();
$stack->push(
Middleware::log(
$logger,
new MessageFormatter('{code}:{method}:{target} {error}')
)
);
return new GuzzleHandler(new Client(['handler' => $stack]));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Bundle\Model\Sales\Order\Shipment;

use Magento\Catalog\Model\Product\Type;
use Magento\Sales\Model\ValidatorInterface;

/**
* Validate if requested order items can be shipped according to bundle product shipment type
*/
class BundleShipmentTypeValidator implements ValidatorInterface
{
/**
* @inheritdoc
*/
public function validate($item)
{
$result = [];
if (!$item->isDummy(true)) {
return $result;
}

$message = 'Cannot create shipment as bundle product "%1" has shipment type "%2". ' .
'%3 should be shipped instead.';

if ($item->getHasChildren() && $item->getProductType() === Type::TYPE_BUNDLE) {
$result[] = __(
$message,
$item->getSku(),
__('Separately'),
__('Bundle product options'),
);
}

if ($item->getParentItem() && $item->getParentItem()->getProductType() === Type::TYPE_BUNDLE) {
$result[] = __(
$message,
$item->getParentItem()->getSku(),
__('Together'),
__('Bundle product itself'),
);
}

return $result;
}
}
23 changes: 23 additions & 0 deletions app/code/Magento/Bundle/Test/Mftf/Test/AdminAddBundleItemsTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@
</actionGroup>
<checkOption selector="{{AdminAddProductsToOptionPanel.firstCheckbox}}" stepKey="selectFirstGridRow2"/>
<click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddSelectedBundleProducts"/>
<!-- Check that Bundle Options initialized with default quantity -->
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" stepKey="grabbedFirstBundleOptionQuantity"/>
<assertEquals stepKey="assertFirstBundleOptionDefaultQuantity">
<expectedResult type="string">1</expectedResult>
<actualResult type="string">$grabbedFirstBundleOptionQuantity</actualResult>
</assertEquals>
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" stepKey="grabbedSecondBundleOptionQuantity"/>
<assertEquals stepKey="assertSecondBundleOptionDefaultQuantity">
<expectedResult type="string">1</expectedResult>
<actualResult type="string">$grabbedSecondBundleOptionQuantity</actualResult>
</assertEquals>

<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty1"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty2"/>

Expand Down Expand Up @@ -108,6 +120,17 @@
</actionGroup>
<checkOption selector="{{AdminProductFormBundleSection.firstProductOption}}" stepKey="selectNewFirstGridRow2"/>
<click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddNewSelectedBundleProducts"/>
<!-- Check that existing Bundle Options do not loose user input quantity values -->
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" stepKey="grabbedFirstBundleOptionQuantityAfterUserInput"/>
<assertEquals stepKey="assertFirstBundleOptionDefaultQuantityAfterUserInput">
<expectedResult type="string">{{BundleProduct.defaultQuantity}}</expectedResult>
<actualResult type="string">$grabbedFirstBundleOptionQuantityAfterUserInput</actualResult>
</assertEquals>
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" stepKey="grabbedSecondBundleOptionQuantityAfterUserInput"/>
<assertEquals stepKey="assertSecondBundleOptionDefaultQuantityAfterUserInput">
<expectedResult type="string">{{BundleProduct.defaultQuantity}}</expectedResult>
<actualResult type="string">$grabbedSecondBundleOptionQuantityAfterUserInput</actualResult>
</assertEquals>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '2')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillNewProductDefaultQty1"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '3')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillNewProductDefaultQty2"/>

Expand Down
7 changes: 7 additions & 0 deletions app/code/Magento/Bundle/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,11 @@
</argument>
</arguments>
</type>
<type name="Magento\Sales\Model\Order\Shipment\ShipmentItemsValidator">
<arguments>
<argument name="validators" xsi:type="array">
<item name="shipment_type" xsi:type="object">Magento\Bundle\Model\Sales\Order\Shipment\BundleShipmentTypeValidator</item>
</argument>
</arguments>
</type>
</config>
3 changes: 3 additions & 0 deletions app/code/Magento/Bundle/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@ Select...,Select...
Status,Status
Thumbnail,Thumbnail
Type,Type
"Cannot create shipment as bundle product ""%1"" has shipment type ""%2"". %3 should be shipped instead.","Cannot create shipment as bundle product ""%1"" has shipment type ""%2"". %3 should be shipped instead."
"Bundle product itself","Bundle product itself"
"Bundle product options","Bundle product options"
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ define([
}
},

/**
* @inheritdoc
*/
setInitialValue: function () {
this.initialValue = this.getInitialValue();

if (this.initialValue === undefined || this.initialValue === '') {
this.initialValue = 1;
}

if (this.value.peek() !== this.initialValue) {
this.value(this.initialValue);
}

this.on('value', this.onUpdate.bind(this));
this.isUseDefault(this.disabled());

return this;
},

/**
* @inheritdoc
*/
Expand All @@ -33,6 +53,5 @@ define([

return !this.visible() ? false : notEqual;
}

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

namespace Magento\Catalog\Block\Product\View\Options;

use Magento\Catalog\Pricing\Price\BasePrice;
use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule;
use Magento\Catalog\Pricing\Price\CustomOptionPriceInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;

/**
* Product options section abstract block.
Expand Down Expand Up @@ -55,24 +56,42 @@ abstract class AbstractOptions extends \Magento\Framework\View\Element\Template
*/
private $calculateCustomOptionCatalogRule;

/**
* @var CalculatorInterface
*/
private $calculator;

/**
* @var PriceCurrencyInterface
*/
private $priceCurrency;

/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Framework\Pricing\Helper\Data $pricingHelper
* @param \Magento\Catalog\Helper\Data $catalogData
* @param array $data
* @param CalculateCustomOptionCatalogRule|null $calculateCustomOptionCatalogRule
* @param CalculatorInterface|null $calculator
* @param PriceCurrencyInterface|null $priceCurrency
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\Pricing\Helper\Data $pricingHelper,
\Magento\Catalog\Helper\Data $catalogData,
array $data = [],
CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null
CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null,
CalculatorInterface $calculator = null,
PriceCurrencyInterface $priceCurrency = null
) {
$this->pricingHelper = $pricingHelper;
$this->_catalogHelper = $catalogData;
$this->calculateCustomOptionCatalogRule = $calculateCustomOptionCatalogRule
?? ObjectManager::getInstance()->get(CalculateCustomOptionCatalogRule::class);
$this->calculator = $calculator
?? ObjectManager::getInstance()->get(CalculatorInterface::class);
$this->priceCurrency = $priceCurrency
?? ObjectManager::getInstance()->get(PriceCurrencyInterface::class);
parent::__construct($context, $data);
}

Expand Down Expand Up @@ -188,7 +207,13 @@ protected function _formatPrice($value, $flag = true)
}

$context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true];
$optionAmount = $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context);
$optionAmount = $isPercent
? $this->calculator->getAmount(
$this->priceCurrency->roundPrice($value['pricing_value']),
$this->getProduct(),
null,
$context
) : $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context);
$priceStr .= $this->getLayout()->getBlock('product.price.render.default')->renderAmount(
$optionAmount,
$customOptionPrice,
Expand Down
Loading

0 comments on commit d21a4fd

Please sign in to comment.