Skip to content

Commit

Permalink
Merge pull request #6622 from magento-tsg/2.4-develop-pr123
Browse files Browse the repository at this point in the history
[Arrows] Fixes for 2.4 (pr123) (2.4-develop)
  • Loading branch information
zakdma authored Feb 12, 2021
2 parents 0d3d7bb + dcd898d commit 2b943ed
Show file tree
Hide file tree
Showing 25 changed files with 755 additions and 107 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Plugin\Api\ProductLinkRepositoryInterface;

use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Api\ProductLinkRepositoryInterface;
use Magento\Catalog\Model\Indexer\Product\Full as FullProductIndexer;

/**
* Product reindexing after delete by id links plugin.
*/
class ReindexAfterDeleteByIdProductLinksPlugin
{
/**
* @var FullProductIndexer
*/
private $fullProductIndexer;

/**
* @var ProductRepositoryInterface
*/
private $productRepository;

/**
* @param FullProductIndexer $fullProductIndexer
* @param ProductRepositoryInterface $productRepository
*/
public function __construct(FullProductIndexer $fullProductIndexer, ProductRepositoryInterface $productRepository)
{
$this->fullProductIndexer = $fullProductIndexer;
$this->productRepository = $productRepository;
}

/**
* Complex reindex after product links has been deleted.
*
* @param ProductLinkRepositoryInterface $subject
* @param bool $result
* @param string $sku
* @param string $type
* @param string $linkedProductSku
* @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterDeleteById(ProductLinkRepositoryInterface $subject, bool $result, $sku): bool
{
$product = $this->productRepository->get($sku);
$this->fullProductIndexer->executeRow($product->getId());

return $result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Plugin\Api\ProductLinkRepositoryInterface;

use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Api\ProductLinkRepositoryInterface;
use Magento\Catalog\Api\Data\ProductLinkInterface;
use Magento\Catalog\Model\Indexer\Product\Full as FullProductIndexer;

/**
* Product reindexing after save links plugin.
*/
class ReindexAfterSaveProductLinksPlugin
{
/**
* @var FullProductIndexer
*/
private $fullProductIndexer;

/**
* @var ProductRepositoryInterface
*/
private $productRepository;

/**
* @param FullProductIndexer $fullProductIndexer
* @param ProductRepositoryInterface $productRepository
*/
public function __construct(FullProductIndexer $fullProductIndexer, ProductRepositoryInterface $productRepository)
{
$this->fullProductIndexer = $fullProductIndexer;
$this->productRepository = $productRepository;
}

/**
* Complex reindex after product links has been saved.
*
* @param ProductLinkRepositoryInterface $subject
* @param bool $result
* @param ProductLinkInterface $entity
* @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterSave(ProductLinkRepositoryInterface $subject, bool $result, ProductLinkInterface $entity): bool
{
$product = $this->productRepository->get($entity->getSku());
$this->fullProductIndexer->executeRow($product->getId());

return $result;
}
}
4 changes: 4 additions & 0 deletions app/code/Magento/Catalog/etc/webapi_rest/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@
<argument name="deserializer" xsi:type="object">Magento\Catalog\Model\Product\Webapi\Rest\RequestTypeBasedDeserializer</argument>
</arguments>
</type>
<type name="Magento\Catalog\Api\ProductLinkRepositoryInterface">
<plugin name="reindex_after_save_product_links" type="Magento\Catalog\Plugin\Api\ProductLinkRepositoryInterface\ReindexAfterSaveProductLinksPlugin"/>
<plugin name="reindex_after_delete_by_id_product_links" type="Magento\Catalog\Plugin\Api\ProductLinkRepositoryInterface\ReindexAfterDeleteByIdProductLinksPlugin"/>
</type>
</config>
4 changes: 4 additions & 0 deletions app/code/Magento/Catalog/etc/webapi_soap/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@
<argument name="deserializer" xsi:type="object">Magento\Framework\Webapi\Rest\Request\Deserializer\Xml</argument>
</arguments>
</type>
<type name="Magento\Catalog\Api\ProductLinkRepositoryInterface">
<plugin name="reindex_after_save_product_links" type="Magento\Catalog\Plugin\Api\ProductLinkRepositoryInterface\ReindexAfterSaveProductLinksPlugin"/>
<plugin name="reindex_after_delete_by_id_product_links" type="Magento\Catalog\Plugin\Api\ProductLinkRepositoryInterface\ReindexAfterDeleteByIdProductLinksPlugin"/>
</type>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ define([
* Initialize object
*/
initialize: function () {
var self = this;
var self = this,
popupDialog = jQuery('#product_composite_configure');

this._initWindowElements();
jQuery.async('#product_composite_configure', function (el) {
if (el !== popupDialog[0]) {
el = popupDialog[0];
}
self.dialog = jQuery(el).modal({
title: jQuery.mage.__('Configure Product'),
type: 'slide',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@
* See COPYING.txt for license details.
*/

/** @var $block \Magento\Checkout\Block\Onepage\Link */
use Magento\Checkout\Block\Onepage\Link;
use Magento\Framework\Escaper;

/**
* @var Link $block
* @var Escaper $escaper
*/
?>
<?php if ($block->isPossibleOnepageCheckout()) :?>
<?php if ($block->isPossibleOnepageCheckout()): ?>
<button type="button"
data-role="proceed-to-checkout"
title="<?= $block->escapeHtmlAttr(__('Proceed to Checkout')) ?>"
title="<?= $escaper->escapeHtmlAttr(__('Proceed to Checkout')) ?>"
data-mage-init='{
"Magento_Checkout/js/proceed-to-checkout":{
"checkoutUrl":"<?= $block->escapeJs($block->escapeUrl($block->getCheckoutUrl())) ?>"
"checkoutUrl":"<?= $escaper->escapeJs($block->getCheckoutUrl()) ?>"
}
}'
class="action primary checkout<?= ($block->isDisabled()) ? ' disabled' : '' ?>"
<?php if ($block->isDisabled()) :?>
<?php if ($block->isDisabled()): ?>
disabled="disabled"
<?php endif; ?>>
<span><?= $block->escapeHtml(__('Proceed to Checkout')) ?></span>
<span><?= $escaper->escapeHtml(__('Proceed to Checkout')) ?></span>
</button>
<?php endif?>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ define([
quoteItems(newValue.items);
});

if (quoteSubtotal !== subtotalAmount) {
if (!isNaN(subtotalAmount) && quoteSubtotal !== subtotalAmount) {
customerData.reload(['cart'], false);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminCustomerWishlistConfigureItemActionGroup">
<arguments>
<argument name="title" type="string" defaultValue="{{Attribute.label}}"/>
<argument name="option" type="string" defaultValue="option1"/>
<argument name="quantity" type="string" defaultValue="2"/>
<argument name="productName" type="string" defaultValue="{{ApiConfigurableProductWithOutCategory.name}}"/>
</arguments>
<click selector="{{AdminCustomerWishlistSection.configureButton(productName)}}" stepKey="clickConfigureButton"/>
<waitForElementVisible selector="{{AdminCustomerWishlistSection.productAttributeOptionsDropDown(title)}}" stepKey="waitForConfigurableOption"/>
<selectOption selector="{{AdminCustomerWishlistSection.productAttributeOptionsDropDown(title)}}" userInput="{{option}}" stepKey="selectConfigurableOption"/>
<fillField selector="{{AdminOrderFormConfigureProductSection.quantity}}" userInput="{{quantity}}" stepKey="fillQty"/>
<click selector="{{AdminOrderFormConfigureProductSection.ok}}" stepKey="confirmSave"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@
<element name="deleteButton" type="text" selector="//*[@id='wishlistGrid_table']//*[@data-column='action']//*[text()='Delete']"/>
<element name="deleteConfirm" type="button" selector=".modal-popup.confirm .action-primary.action-accept"/>
<element name="gridTable" type="text" selector="#wishlistGrid_table"/>
<element name="configureButton" type="text" selector="//table[@id='wishlistGrid_table']//tbody//td[@data-column='product_name' and contains(text(),'{{productName}}')]/parent::tr//td[@data-column='action']//a[@class='configure-item-link']" timeout="30" parameterized="true"/>
<element name="productAttributeOptionsDropDown" type="text" selector="//label[contains(.,'{{var1}}')]/following::div[contains(@class,'control')]//select" parameterized="true"/>
<element name="productQty" type="text" selector="table#wishlistGrid_table td.col-number[data-column=qty]"/>
</section>
</sections>
6 changes: 5 additions & 1 deletion app/code/Magento/Downloadable/Model/Link/DeleteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Magento\Framework\EntityManager\Operation\ExtensionInterface;

/**
* Class DeleteHandler
* Delete Handler for Downloadable Product Links.
*/
class DeleteHandler implements ExtensionInterface
{
Expand All @@ -27,6 +27,8 @@ public function __construct(LinkRepository $linkRepository)
}

/**
* Delete Downloadable Links for the provided Product.
*
* @param object $entity
* @param array $arguments
* @return \Magento\Catalog\Api\Data\ProductInterface|object
Expand All @@ -41,6 +43,8 @@ public function execute($entity, $arguments = [])
foreach ($this->linkRepository->getList($entity->getSku()) as $link) {
$this->linkRepository->delete($link->getId());
}
$entity->setDownloadableLinks(null);

return $entity;
}
}
9 changes: 5 additions & 4 deletions app/code/Magento/Downloadable/Model/Link/ReadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Magento\Framework\EntityManager\Operation\ExtensionInterface;

/**
* Class ReadHandler
* Read Handler for Downloadable Product Links.
*/
class ReadHandler implements ExtensionInterface
{
Expand All @@ -27,6 +27,8 @@ public function __construct(LinkRepository $linkRepository)
}

/**
* Read Downloadable Links for the provided Product.
*
* @param object $entity
* @param array $arguments
* @return \Magento\Catalog\Api\Data\ProductInterface|object
Expand All @@ -40,10 +42,9 @@ public function execute($entity, $arguments = [])
}
$entityExtension = $entity->getExtensionAttributes();
$links = $this->linkRepository->getLinksByProduct($entity);
if ($links) {
$entityExtension->setDownloadableProductLinks($links);
}
$entityExtension->setDownloadableProductLinks($links);
$entity->setExtensionAttributes($entityExtension);

return $entity;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertStorefrontLinkOnDownloadableProductPageActionGroup">
<annotations>
<description>Validates that the provided Link Title is present on Downloadable Product details page.</description>
</annotations>
<arguments>
<argument name="linkTitle" type="string" defaultValue="{{downloadableLink.title}}"/>
</arguments>

<waitForElementVisible selector="{{StorefrontDownloadableProductSection.downloadableLinksListSection}}" stepKey="waitForDownloadableLinksList"/>
<see selector="{{StorefrontDownloadableProductSection.downloadableLinksListSection}}" userInput="{{linkTitle}}" stepKey="seeDownloadableLink"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertStorefrontNoLinkOnDownloadableProductPageActionGroup">
<annotations>
<description>Validates that the provided Link Title is NOT present on Downloadable Product details page.</description>
</annotations>
<arguments>
<argument name="linkTitle" type="string" defaultValue="{{downloadableLink.title}}"/>
</arguments>

<waitForElementVisible selector="{{StorefrontDownloadableProductSection.downloadableLinksListSection}}" stepKey="waitForDownloadableLinksList"/>
<dontSee selector="{{StorefrontDownloadableProductSection.downloadableLinksListSection}}" userInput="{{linkTitle}}" stepKey="dontSeeDownloadableLink"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
<element name="downloadableSampleLabel" type="text" selector="//a[contains(.,normalize-space('{{title}}'))]" parameterized="true" timeout="30"/>
<element name="downloadableLinkSelectAllCheckbox" type="checkbox" selector="#links_all" />
<element name="downloadableLinkSelectAllLabel" type="text" selector="label[for='links_all']" />
<element name="downloadableLinksListSection" type="text" selector="#downloadable-links-list" timeout="30"/>
</section>
</sections>
Loading

0 comments on commit 2b943ed

Please sign in to comment.