Skip to content

Commit

Permalink
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop
Browse files Browse the repository at this point in the history
Accepted Community Pull Requests:
 - #26170: Fixed Special Price class not added in configurable product page (by @ravi-chandra3197)
 - #26173: Added Fix for 26164 (by @divyajyothi5321)
 - #25876: Advance the order state to processing when a capture notification is received (by @azambon)
 - #25125: Performance optimizations (by @andrey-legayev)
 - #25428: Fixed model save and ObjectManager usage (by @drpayyne)


Fixed GitHub Issues:
 - #24972: Special Price class not added in configurable product page (reported by @k-edasi) has been fixed in #26170 by @ravi-chandra3197 in 2.4-develop branch
   Related commits:
     1. 666d4c0
     2. e037d51

 - #26164: Underline should not display on hover for delete icon at shopping cart Internet explorer browser (reported by @hasim32) has been fixed in #26173 by @divyajyothi5321 in 2.4-develop branch
   Related commits:
     1. 216d2c1

 - #25659: Paypal Payments Pro IPN keeping payments marked as Pending Payment (reported by @quantumAV) has been fixed in #25876 by @azambon in 2.4-develop branch
   Related commits:
     1. 45592e2
  • Loading branch information
VladimirZaets authored Dec 30, 2019
2 parents 34ef309 + a7ce2ae commit 10ab84e
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,16 @@ protected function _getWebsiteCurrencyRates()
);
foreach ($this->_storeManager->getWebsites() as $website) {
/* @var $website \Magento\Store\Model\Website */
if ($website->getBaseCurrencyCode() != $baseCurrency) {
$websiteBaseCurrency = $website->getBaseCurrencyCode();
if ($websiteBaseCurrency !== $baseCurrency) {
$rate = $this->_currencyFactory->create()->load(
$baseCurrency
)->getRate(
$website->getBaseCurrencyCode()
);
)->getRate($websiteBaseCurrency);
if (!$rate) {
$rate = 1;
}
$this->_rates[$website->getId()] = [
'code' => $website->getBaseCurrencyCode(),
'code' => $websiteBaseCurrency,
'rate' => $rate,
];
} else {
Expand Down Expand Up @@ -187,6 +186,7 @@ public function validate($object)
}
$compare = implode(
'-',
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
array_merge(
[$priceRow['website_id'], $priceRow['cust_group']],
$this->_getAdditionalUniqueFields($priceRow)
Expand All @@ -210,6 +210,7 @@ public function validate($object)
if ($price['website_id'] == 0) {
$compare = implode(
'-',
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
array_merge(
[$price['website_id'], $price['cust_group']],
$this->_getAdditionalUniqueFields($price)
Expand All @@ -234,6 +235,7 @@ public function validate($object)

$globalCompare = implode(
'-',
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
array_merge([0, $priceRow['cust_group']], $this->_getAdditionalUniqueFields($priceRow))
);
$websiteCurrency = $rates[$priceRow['website_id']]['code'];
Expand Down Expand Up @@ -279,6 +281,7 @@ public function preparePriceData(array $priceData, $productTypeId, $websiteId)
if (!array_filter($v)) {
continue;
}
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
$key = implode('-', array_merge([$v['cust_group']], $this->_getAdditionalUniqueFields($v)));
if ($v['website_id'] == $websiteId) {
$data[$key] = $v;
Expand Down
25 changes: 13 additions & 12 deletions app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute implements

const KEY_IS_GLOBAL = 'is_global';

private const ALLOWED_INPUT_TYPES = [
'boolean' => true,
'date' => true,
'datetime' => true,
'multiselect' => true,
'price' => true,
'select' => true,
'text' => true,
'textarea' => true,
'weight' => true,
];

/**
* @var LockValidatorInterface
*/
Expand Down Expand Up @@ -403,18 +415,7 @@ public function getSourceModel()
*/
public function isAllowedForRuleCondition()
{
$allowedInputTypes = [
'boolean',
'date',
'datetime',
'multiselect',
'price',
'select',
'text',
'textarea',
'weight',
];
return $this->getIsVisible() && in_array($this->getFrontendInput(), $allowedInputTypes);
return $this->getIsVisible() && isset(self::ALLOWED_INPUT_TYPES[$this->getFrontendInput()]);
}

/**
Expand Down
72 changes: 58 additions & 14 deletions app/code/Magento/Email/Controller/Adminhtml/Email/Template/Save.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,63 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Email\Controller\Adminhtml\Email\Template;

use Exception;
use Magento\Backend\App\Action\Context;
use Magento\Backend\Model\Session;
use Magento\Email\Controller\Adminhtml\Email\Template;
use Magento\Email\Model\ResourceModel\Template as TemplateResource;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\TemplateTypesInterface;
use Magento\Framework\Registry;
use Magento\Framework\Stdlib\DateTime\DateTime;

class Save extends \Magento\Email\Controller\Adminhtml\Email\Template
/**
* Save Controller
*/
class Save extends Template implements HttpPostActionInterface
{
/**
* @var DateTime
*/
private $dateTime;

/**
* @var TemplateResource
*/
private $templateResource;

/**
* @var Session
*/
private $backendSession;

/**
* Save constructor
*
* @param Context $context
* @param Registry $coreRegistry
* @param DateTime|null $dateTime
* @param TemplateResource|null $templateResource
* @param Session|null $backendSession
*/
public function __construct(
Context $context,
Registry $coreRegistry,
DateTime $dateTime = null,
TemplateResource $templateResource = null,
Session $backendSession = null
) {
$this->dateTime = $dateTime ?: ObjectManager::getInstance()->get(DateTime::class);
$this->templateResource = $templateResource ?: ObjectManager::getInstance()->get(TemplateResource::class);
$this->backendSession = $backendSession ?: ObjectManager::getInstance()->get(Session::class);
parent::__construct($context, $coreRegistry);
}

/**
* Save transactional email action
*
Expand All @@ -18,10 +66,10 @@ class Save extends \Magento\Email\Controller\Adminhtml\Email\Template
public function execute()
{
$request = $this->getRequest();
$id = $this->getRequest()->getParam('id');
$templateId = $this->getRequest()->getParam('id');

$template = $this->_initTemplate('id');
if (!$template->getId() && $id) {
if (!$template->getId() && $templateId) {
$this->messageManager->addErrorMessage(__('This email template no longer exists.'));
$this->_redirect('adminhtml/*/');
return;
Expand All @@ -37,7 +85,7 @@ public function execute()
)->setTemplateStyles(
$request->getParam('template_styles')
)->setModifiedAt(
$this->_objectManager->get(\Magento\Framework\Stdlib\DateTime\DateTime::class)->gmtDate()
$this->dateTime->gmtDate()
)->setOrigTemplateCode(
$request->getParam('orig_template_code')
)->setOrigTemplateVariables(
Expand All @@ -53,17 +101,13 @@ public function execute()
$template->setTemplateStyles('');
}

$template->save();
$this->_objectManager->get(\Magento\Backend\Model\Session::class)->setFormData(false);
$this->templateResource->save($template);

$this->backendSession->setFormData(false);
$this->messageManager->addSuccessMessage(__('You saved the email template.'));
$this->_redirect('adminhtml/*');
} catch (\Exception $e) {
$this->_objectManager->get(
\Magento\Backend\Model\Session::class
)->setData(
'email_template_form_data',
$request->getParams()
);
} catch (Exception $e) {
$this->backendSession->setData('email_template_form_data', $request->getParams());
$this->messageManager->addErrorMessage($e->getMessage());
$this->_forward('new');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\StatusResolver;

/**
* Class RegisterCaptureNotificationCommand
*
* Command that Register Capture Notification
*/
class RegisterCaptureNotificationCommand implements CommandInterface
{
/**
Expand All @@ -23,19 +28,24 @@ class RegisterCaptureNotificationCommand implements CommandInterface
*/
public function __construct(StatusResolver $statusResolver = null)
{
$this->statusResolver = $statusResolver
? : ObjectManager::getInstance()->get(StatusResolver::class);
$this->statusResolver = $statusResolver ?: ObjectManager::getInstance()->get(StatusResolver::class);
}

/**
* Registers a capture event for this payment
*
* @param OrderPaymentInterface $payment
* @param string|float|int $amount
* @param OrderInterface $order
* @return string
*/
public function execute(OrderPaymentInterface $payment, $amount, OrderInterface $order)
{
$state = $order->getState() ?: Order::STATE_PROCESSING;
$state = $order->getState();
if (!$state || $state === Order::STATE_NEW || $state === Order::STATE_PENDING_PAYMENT) {
$state = Order::STATE_PROCESSING;
}

$status = null;
$message = 'Registered notification about captured amount of %1.';

Expand All @@ -61,6 +71,8 @@ public function execute(OrderPaymentInterface $payment, $amount, OrderInterface
}

/**
* Sets the state and status of the order
*
* @deprecated 100.2.0 Replaced by a StatusResolver class call.
*
* @param Order $order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ public function commandResultDataProvider()
$this->newOrderStatus,
'Registered notification about captured amount of %1.',
],
[
false,
false,
Order::STATE_NEW,
Order::STATE_PROCESSING,
$this->newOrderStatus,
'Registered notification about captured amount of %1.',
],
[
false,
false,
Order::STATE_PENDING_PAYMENT,
Order::STATE_PROCESSING,
$this->newOrderStatus,
'Registered notification about captured amount of %1.',
],
[
true,
false,
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,8 @@ define([

isShow = typeof result != 'undefined' && result.oldPrice.amount !== result.finalPrice.amount;

$productPrice.find('span:first').toggleClass('special-price', isShow);

$product.find(this.options.slyOldPriceSelector)[isShow ? 'show' : 'hide']();

if (typeof result != 'undefined' && result.tierPrices && result.tierPrices.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@
.lib-icon-font-symbol(
@_icon-font-content: @icon-trash
);

&:hover {
.lib-css(text-decoration, @link__text-decoration);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ define([
id: optionId
}]
};

widget.options = {
classes: {
optionClass: 'swatch-option'
Expand All @@ -50,6 +51,7 @@ define([
}
}
};

optionConfig = widget.options.jsonSwatchConfig[attribute.id];
html = $(widget._RenderSwatchOptions(attribute, 'option-label-control-id-1'))[0];
});
Expand All @@ -76,5 +78,25 @@ define([
expect(html.style.height).toEqual(swathImageHeight + 'px');
expect(html.style.width).toEqual(swathImageWidth + 'px');
});

it('check udate price method', function () {
var productPriceMock = {
find: jasmine.createSpy().and.returnValue({
hide: jasmine.createSpy(),
priceBox: jasmine.createSpy().and.returnValue(''),
trigger: jasmine.createSpy(),
find: jasmine.createSpy().and.returnValue({
toggleClass: jasmine.createSpy()
})
})
};

widget.element = {
parents: jasmine.createSpy().and.returnValue(productPriceMock)
};
widget._getNewPrices = jasmine.createSpy().and.returnValue(undefined);
widget._UpdatePrice();
expect(productPriceMock.find().find.calls.count()).toBe(1);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\App\ObjectManager\ConfigLoader;

use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\ObjectManager\ConfigLoaderInterface;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Framework\Serialize\Serializer\Serialize;

/**
* Load configuration files
*/
class Compiled implements ConfigLoaderInterface
{
/**
Expand All @@ -21,7 +21,7 @@ class Compiled implements ConfigLoaderInterface
private $configCache = [];

/**
* {inheritdoc}
* @inheritdoc
*/
public function load($area)
{
Expand Down
10 changes: 8 additions & 2 deletions lib/internal/Magento/Framework/DB/Select/SelectRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@
use Magento\Framework\DB\Select;

/**
* Class SelectRenderer
* Phrase renderer interface
*/
class SelectRenderer implements RendererInterface
{
private const MANDATORY_SELECT_PARTS = [
Select::COLUMNS => true,
Select::FROM => true
];

/**
* @var RendererInterface[]
*/
Expand Down Expand Up @@ -67,7 +72,8 @@ public function render(Select $select, $sql = '')
{
$sql = Select::SQL_SELECT;
foreach ($this->renderers as $renderer) {
if (in_array($renderer['part'], [Select::COLUMNS, Select::FROM]) || $select->getPart($renderer['part'])) {
$part = $renderer['part'];
if (isset(self::MANDATORY_SELECT_PARTS[$part]) || $select->getPart($part)) {
$sql = $renderer['renderer']->render($select, $sql);
}
}
Expand Down
Loading

0 comments on commit 10ab84e

Please sign in to comment.