Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.3-develop' into MAGETWO-98105
Browse files Browse the repository at this point in the history
  • Loading branch information
olysenko committed Feb 14, 2019
2 parents 67e5620 + d1ce6a4 commit c952238
Show file tree
Hide file tree
Showing 60 changed files with 1,476 additions and 215 deletions.
18 changes: 16 additions & 2 deletions app/code/Magento/AsynchronousOperations/Model/MassConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Magento\AsynchronousOperations\Model;

use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Registry;
use Psr\Log\LoggerInterface;
use Magento\Framework\MessageQueue\MessageLockException;
use Magento\Framework\MessageQueue\ConnectionLostException;
Expand Down Expand Up @@ -58,6 +59,11 @@ class MassConsumer implements ConsumerInterface
*/
private $operationProcessor;

/**
* @var Registry
*/
private $registry;

/**
* Initialize dependencies.
*
Expand All @@ -67,14 +73,16 @@ class MassConsumer implements ConsumerInterface
* @param ConsumerConfigurationInterface $configuration
* @param OperationProcessorFactory $operationProcessorFactory
* @param LoggerInterface $logger
* @param Registry $registry
*/
public function __construct(
CallbackInvoker $invoker,
ResourceConnection $resource,
MessageController $messageController,
ConsumerConfigurationInterface $configuration,
OperationProcessorFactory $operationProcessorFactory,
LoggerInterface $logger
LoggerInterface $logger,
Registry $registry = null
) {
$this->invoker = $invoker;
$this->resource = $resource;
Expand All @@ -84,20 +92,26 @@ public function __construct(
'configuration' => $configuration
]);
$this->logger = $logger;
$this->registry = $registry ?? \Magento\Framework\App\ObjectManager::getInstance()
->get(Registry::class);
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function process($maxNumberOfMessages = null)
{
$this->registry->register('isSecureArea', true, true);

$queue = $this->configuration->getQueue();

if (!isset($maxNumberOfMessages)) {
$queue->subscribe($this->getTransactionCallback($queue));
} else {
$this->invoker->invoke($queue, $maxNumberOfMessages, $this->getTransactionCallback($queue));
}

$this->registry->unregister('isSecureArea');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ $isElementReadonly = $block->getElement()
->getReadonly();
?>

<?php if (!($attributeCode === 'price' && $block->getCanReadPrice() === false)) { ?>
<?php if (!($attributeCode === 'price' && $block->getCanReadPrice() === false)): ?>
<div class="<?= /* @escapeNotVerified */ $attributeCode ?> "><?= /* @escapeNotVerified */ $elementHtml ?></div>
<?php } ?>
<?php endif; ?>

<?= $block->getExtendedElement($switchAttributeCode)->toHtml() ?>

Expand All @@ -43,13 +43,13 @@ $isElementReadonly = $block->getElement()
} else {
if ($attribute) {
<?php if ($attributeCode === 'price' && !$block->getCanEditPrice() && $block->getCanReadPrice()
&& $block->getProduct()->isObjectNew()) { ?>
&& $block->getProduct()->isObjectNew()): ?>
<?php $defaultProductPrice = $block->getDefaultProductPrice() ?: "''"; ?>
$attribute.value = <?= /* @escapeNotVerified */ $defaultProductPrice ?>;
<?php } else { ?>
<?php else: ?>
$attribute.disabled = false;
$attribute.addClassName('required-entry');
<?php } ?>
<?php endif; ?>
}
if ($('dynamic-price-warning')) {
$('dynamic-price-warning').hide();
Expand All @@ -58,9 +58,9 @@ $isElementReadonly = $block->getElement()
}

<?php if (!($attributeCode === 'price' && !$block->getCanEditPrice()
&& !$block->getProduct()->isObjectNew())) { ?>
&& !$block->getProduct()->isObjectNew())): ?>
$('<?= /* @escapeNotVerified */ $switchAttributeCode ?>').observe('change', <?= /* @escapeNotVerified */ $switchAttributeCode ?>_change);
<?php } ?>
<?php endif; ?>
Event.observe(window, 'load', function(){
<?= /* @escapeNotVerified */ $switchAttributeCode ?>_change();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function execute()
$attributeCode
);

if ($attribute->getId() && !$attributeId || $attributeCode === 'product_type') {
if ($attribute->getId() && !$attributeId || $attributeCode === 'product_type' || $attributeCode === 'type_id') {
$message = strlen($this->getRequest()->getParam('attribute_code'))
? __('An attribute with this code already exists.')
: __('An attribute with the same code (%1) already exists.', $attributeCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

use Magento\Framework\App\ResourceConnection;

/**
* Abstract action class for category flat indexers.
*/
class AbstractAction
{
/**
Expand Down Expand Up @@ -130,7 +133,7 @@ protected function getFlatTableStructure($tableName)
$table = $this->connection->newTable(
$tableName
)->setComment(
sprintf("Catalog Category Flat", $tableName)
'Catalog Category Flat'
);

//Adding columns
Expand Down Expand Up @@ -378,7 +381,7 @@ protected function getAttributeValues($entityIds, $storeId)
$linkField = $this->getCategoryMetadata()->getLinkField();
foreach ($attributesType as $type) {
foreach ($this->getAttributeTypeValues($type, $entityIds, $storeId) as $row) {
if (isset($row[$linkField]) && isset($row['attribute_id'])) {
if (isset($row[$linkField], $row['attribute_id'])) {
$attributeId = $row['attribute_id'];
if (isset($attributes[$attributeId])) {
$attributeCode = $attributes[$attributeId]['attribute_code'];
Expand Down Expand Up @@ -496,6 +499,8 @@ protected function getTableName($name)
}

/**
* Get category metadata instance.
*
* @return \Magento\Framework\EntityManager\EntityMetadata
*/
private function getCategoryMetadata()
Expand All @@ -509,6 +514,8 @@ private function getCategoryMetadata()
}

/**
* Get skip static columns instance.
*
* @return array
*/
private function getSkipStaticColumns()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function _isApplicableAttribute($object, $attribute)
*/
protected function _isCallableAttributeInstance($instance, $method, $args)
{
if ($instance instanceof \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
if ($instance instanceof AbstractBackend
&& ($method == 'beforeSave' || $method == 'afterSave')
) {
$attributeCode = $instance->getAttribute()->getAttributeCode();
Expand Down Expand Up @@ -491,7 +491,7 @@ protected function _canUpdateAttribute(AbstractAttribute $attribute, $value, arr
* Retrieve attribute's raw value from DB.
*
* @param int $entityId
* @param int|string|array $attribute atrribute's ids or codes
* @param int|string|array $attribute attribute's ids or codes
* @param int|\Magento\Store\Model\Store $store
* @return bool|string|array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use Magento\Framework\DB\Select;
use Magento\Store\Model\Store;

/**
* Provide Select object for retrieve product id with minimal price.
*/
class LinkedProductSelectBuilderByBasePrice implements LinkedProductSelectBuilderInterface
{
/**
Expand Down Expand Up @@ -69,7 +72,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function build($productId)
{
Expand All @@ -85,7 +88,7 @@ public function build($productId)
[]
)->joinInner(
[BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS => $productTable],
sprintf('%s.entity_id = link.child_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS, $linkField),
sprintf('%s.entity_id = link.child_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS),
['entity_id']
)->joinInner(
['t' => $priceAttribute->getBackendTable()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@

<fillField stepKey="fillCategoryName" selector="{{AdminProductCategoryCreationSection.nameInput}}" userInput="{{categoryName}}"/>

<!-- Search and select a parent catagory for the product -->
<!-- Search and select a parent category for the product -->
<click stepKey="clickParentCategory" selector="{{AdminProductCategoryCreationSection.parentCategory}}"/>
<waitForPageLoad stepKey="waitForDropDownVisible"/>
<fillField stepKey="searchForParent" userInput="{{parentCategoryName}}" selector="{{AdminProductCategoryCreationSection.parentSearch}}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<button type="submit"
title="<?= /* @escapeNotVerified */ $buttonTitle ?>"
class="action primary tocart"
id="product-addtocart-button">
id="product-addtocart-button" disabled>
<span><?= /* @escapeNotVerified */ $buttonTitle ?></span>
</button>
<?= $block->getChildHtml('', true) ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ define([
$.widget('mage.productValidate', {
options: {
bindSubmit: false,
radioCheckboxClosest: '.nested'
radioCheckboxClosest: '.nested',
addToCartButtonSelector: '.action.tocart'
},

/**
Expand Down Expand Up @@ -41,6 +42,7 @@ define([
return false;
}
});
$(this.options.addToCartButtonSelector).attr('disabled', false);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ protected function _getRatesByCode($code, $toCurrencies = null)
$connection = $this->getConnection();
$bind = [':currency_from' => $code];
$select = $connection->select()->from(
$this->getTable('directory_currency_rate'),
$this->_currencyRateTable,
['currency_to', 'rate']
)->where(
'currency_from = :currency_from'
Expand Down
7 changes: 4 additions & 3 deletions app/code/Magento/Payment/Model/CcConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getConfig()
{
Expand All @@ -69,7 +69,7 @@ public function getIcons()
}

$types = $this->ccConfig->getCcAvailableTypes();
foreach (array_keys($types) as $code) {
foreach ($types as $code => $label) {
if (!array_key_exists($code, $this->icons)) {
$asset = $this->ccConfig->createAsset('Magento_Payment::images/cc/' . strtolower($code) . '.png');
$placeholder = $this->assetSource->findSource($asset);
Expand All @@ -78,7 +78,8 @@ public function getIcons()
$this->icons[$code] = [
'url' => $asset->getUrl(),
'width' => $width,
'height' => $height
'height' => $height,
'title' => __($label),
];
}
}
Expand Down
14 changes: 11 additions & 3 deletions app/code/Magento/Payment/Test/Unit/Model/CcConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ public function testGetConfig()
'vi' => [
'url' => 'http://cc.card/vi.png',
'width' => getimagesize($imagesDirectoryPath . 'vi.png')[0],
'height' => getimagesize($imagesDirectoryPath . 'vi.png')[1]
'height' => getimagesize($imagesDirectoryPath . 'vi.png')[1],
'title' => __('Visa'),
],
'ae' => [
'url' => 'http://cc.card/ae.png',
'width' => getimagesize($imagesDirectoryPath . 'ae.png')[0],
'height' => getimagesize($imagesDirectoryPath . 'ae.png')[1]
'height' => getimagesize($imagesDirectoryPath . 'ae.png')[1],
'title' => __('American Express'),
]
]
]
Expand All @@ -56,19 +58,25 @@ public function testGetConfig()

$ccAvailableTypesMock = [
'vi' => [
'title' => 'Visa',
'fileId' => 'Magento_Payment::images/cc/vi.png',
'path' => $imagesDirectoryPath . 'vi.png',
'url' => 'http://cc.card/vi.png'
],
'ae' => [
'title' => 'American Express',
'fileId' => 'Magento_Payment::images/cc/ae.png',
'path' => $imagesDirectoryPath . 'ae.png',
'url' => 'http://cc.card/ae.png'
]
];
$assetMock = $this->createMock(\Magento\Framework\View\Asset\File::class);

$this->ccConfigMock->expects($this->once())->method('getCcAvailableTypes')->willReturn($ccAvailableTypesMock);
$this->ccConfigMock->expects($this->once())->method('getCcAvailableTypes')
->willReturn(array_combine(
array_keys($ccAvailableTypesMock),
array_column($ccAvailableTypesMock, 'title')
));

$this->ccConfigMock->expects($this->atLeastOnce())
->method('createAsset')
Expand Down
18 changes: 18 additions & 0 deletions app/code/Magento/QuoteGraphQl/Model/Cart/ExtractDataFromCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,36 @@

namespace Magento\QuoteGraphQl\Model\Cart;

use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\Quote\Item as QuoteItem;
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;

/**
* Extract data from cart
*/
class ExtractDataFromCart
{
/**
* @var QuoteIdToMaskedQuoteIdInterface
*/
private $quoteIdToMaskedQuoteId;

/**
* @param QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedQuoteId
*/
public function __construct(
QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedQuoteId
) {
$this->quoteIdToMaskedQuoteId = $quoteIdToMaskedQuoteId;
}

/**
* Extract data from cart
*
* @param Quote $cart
* @return array
* @throws NoSuchEntityException
*/
public function execute(Quote $cart): array
{
Expand All @@ -43,6 +60,7 @@ public function execute(Quote $cart): array
$appliedCoupon = $cart->getCouponCode();

return [
'cart_id' => $this->quoteIdToMaskedQuoteId->execute((int)$cart->getId()),
'items' => $items,
'applied_coupon' => $appliedCoupon ? ['code' => $appliedCoupon] : null
];
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/QuoteGraphQl/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<arguments>
<argument name="supportedTypes" xsi:type="array">
<item name="simple" xsi:type="string">SimpleCartItem</item>
<item name="virtual" xsi:type="string">VirtualCartItem</item>
</argument>
</arguments>
</type>
Expand Down
Loading

0 comments on commit c952238

Please sign in to comment.