Skip to content

Commit

Permalink
Merge branch '2.4-develop' into refactoring-AdminConfigurableProductR…
Browse files Browse the repository at this point in the history
…emoveAnOptionTest
  • Loading branch information
kate-kyzyma committed Mar 12, 2021
2 parents 3831d41 + 7a72b6b commit 1ba52ff
Show file tree
Hide file tree
Showing 30 changed files with 319 additions and 97 deletions.
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/Block/Ui/ProductViewCounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public function getCurrentProductData()
$this->productRenderCollectorComposite
->collect($product, $productRender);
$data = $this->hydrator->extract($productRender);
$data['is_available'] = $product->isAvailable();

$currentProductData = [
'items' => [
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<data key="name">TestFooBar</data>
<data key="sku" unique="suffix">foobar</data>
</entity>
<entity name="ApiSimpleProductWithDoubleSpaces" type="product" extends="ApiSimpleProduct">
<data key="name">Simple Product Double Space</data>
<data key="sku" unique="suffix">simple-product double-space</data>
</entity>
<entity name="ApiSimpleProductWithSpecCharInName" type="product" extends="ApiSimpleProduct">
<data key="name">Pursuit Lumaflex&#38;trade; Tone Band</data>
<data key="sku" unique="suffix">x&#38;trade;</data>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminShowDoubleSpacesInProductGrid">
<annotations>
<features value="Catalog"/>
<stories value="Edit products"/>
<title value="Show double spaces in the product grid"/>
<description value="Admin should be able to see double spaces in the Name and Sku fields in the product grid"/>
<testCaseId value="MC-40725"/>
<useCaseId value="MC-40122"/>
<severity value="AVERAGE"/>
<group value="Catalog"/>
</annotations>

<before>
<createData entity="ApiCategory" stepKey="createCategory"/>
<createData entity="ApiSimpleProductWithDoubleSpaces" stepKey="createProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<magentoCLI command="cron:run --group=index" stepKey="cronRun"/>
<magentoCLI command="cron:run --group=index" stepKey="cronRunSecondTime"/>
</before>

<after>
<actionGroup ref="AdminDeleteAllProductsFromGridActionGroup" stepKey="deleteProduct"/>
<actionGroup ref="ClearFiltersAdminProductGridActionGroup" stepKey="clearGridFilters"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
</after>

<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<actionGroup ref="AdminOpenCatalogProductPageActionGroup" stepKey="goToProductCatalogPage"/>
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="searchForProduct">
<argument name="product" value="$createProduct$"/>
</actionGroup>
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="assertProductName">
<argument name="column" value="Name"/>
<argument name="value" value="$createProduct.name$"/>
</actionGroup>
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="assertProductSku">
<argument name="column" value="SKU"/>
<argument name="value" value="$createProduct.sku$"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ public function testGetCurrentProductDataWithNonEmptyProduct()
{
$productMock = $this->getMockBuilder(ProductInterface::class)
->disableOriginalConstructor()
->addMethods(['isAvailable'])
->getMockForAbstractClass();
$productRendererMock = $this->getMockBuilder(ProductRenderInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$storeMock = $this->getMockBuilder(Store::class)
->disableOriginalConstructor()
->getMock();

$this->registryMock->expects($this->once())
->method('registry')
->with('product')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<settings>
<addField>true</addField>
<filter>text</filter>
<bodyTmpl>ui/grid/cells/html</bodyTmpl>
<bodyTmpl>Magento_Catalog/grid/cells/preserved</bodyTmpl>
<label translate="true">Name</label>
</settings>
</column>
Expand All @@ -155,7 +155,7 @@
<column name="sku" sortOrder="60">
<settings>
<filter>text</filter>
<bodyTmpl>ui/grid/cells/html</bodyTmpl>
<bodyTmpl>Magento_Catalog/grid/cells/preserved</bodyTmpl>
<label translate="true">SKU</label>
</settings>
</column>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<div class="data-grid-cell-content white-space-preserved" html="$col.getLabel($row())"/>
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ define([
return row['is_salable'];
},

/**
* Depends on this option, stock status text can be "In stock" or "Out Of Stock"
*
* @param {Object} row
* @returns {Boolean}
*/
isAvailable: function (row) {
return row['is_available'];
},

/**
* Depends on this option, "Add to cart" button can be shown or hide. Depends on backend configuration
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</button>
</form>
<?php else :?>
<?php if ($item->getIsSalable()) :?>
<?php if ($item->isAvailable()) :?>
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
<?php else :?>
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ $_helper = $block->getData('outputHelper');
<?php endforeach; ?>
</ol>
</div>
<?= $block->getToolbarHtml() ?>
<?= $block->getChildBlock('toolbar')->setIsBottom(true)->toHtml() ?>
<script type="text/x-magento-init">
{
"[data-role=tocart-form], .form.map.checkout": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ $_item = null;
</form>
<?php endif; ?>
<?php else:?>
<?php if ($_item->getIsSalable()):?>
<?php if ($_item->isAvailable()):?>
<div class="stock available">
<span><?= $block->escapeHtml(__('In stock')) ?></span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,23 @@
*
* @var $block \Magento\Catalog\Block\Product\ProductList\Toolbar
*/

// phpcs:disable Magento2.Security.IncludeFile.FoundIncludeFile
// phpcs:disable PSR2.Methods.FunctionCallSignature.SpaceBeforeOpenBracket
?>
<?php if ($block->getCollection()->getSize()) :?>
<?php $widget = $this->helper(\Magento\Framework\Json\Helper\Data::class)->jsonDecode($block->getWidgetOptionsJson());
$widgetOptions = $this->helper(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($widget['productListToolbarForm']);
?>
<div class="toolbar toolbar-products" data-mage-init='{"productListToolbarForm":<?= /* @noEscape */ $widgetOptions ?>}'>
<?php if ($block->isExpanded()) :?>
<?php include ($block->getTemplateFile('Magento_Catalog::product/list/toolbar/viewmode.phtml')) ?>
<?php endif; ?>

<?php include ($block->getTemplateFile('Magento_Catalog::product/list/toolbar/amount.phtml')) ?>

<?= $block->getPagerHtml() ?>

<?php include ($block->getTemplateFile('Magento_Catalog::product/list/toolbar/limiter.phtml')) ?>

<?php if ($block->isExpanded()) :?>
<?php include ($block->getTemplateFile('Magento_Catalog::product/list/toolbar/sorter.phtml')) ?>
<?php endif; ?>
<?php if ($block->getIsBottom()): ?>
<?= $block->getPagerHtml() ?>
<?= $block->fetchView($block->getTemplateFile('Magento_Catalog::product/list/toolbar/limiter.phtml')) ?>
<?php else: ?>
<?php if ($block->isExpanded()): ?>
<?= $block->fetchView($block->getTemplateFile('Magento_Catalog::product/list/toolbar/viewmode.phtml')) ?>
<?php endif ?>
<?= $block->fetchView($block->getTemplateFile('Magento_Catalog::product/list/toolbar/amount.phtml')) ?>
<?php if ($block->isExpanded()): ?>
<?= $block->fetchView($block->getTemplateFile('Magento_Catalog::product/list/toolbar/sorter.phtml')) ?>
<?php endif ?>
<?php endif ?>
</div>
<?php endif ?>
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class);
. ' data-mage-init=\'{ "redirectUrl": { "event": "click", url: "' . $block->escapeUrl($block->getAddToCartUrl($_product)) . '"} }\'>'
. '<span>' . $block->escapeHtml(__('Add to Cart')) . '</span></button>';
} else {
$info['button'] = $_product->getIsSalable() ? '<div class="stock available"><span>' . $block->escapeHtml(__('In stock')) . '</span></div>' :
$info['button'] = $_product->isAvailable() ? '<div class="stock available"><span>' . $block->escapeHtml(__('In stock')) . '</span></div>' :
'<div class="stock unavailable"><span>' . $block->escapeHtml(__('Out of stock')) . '</span></div>';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</button>
<?php endif; ?>
<?php else :?>
<?php if ($_product->getIsSalable()) :?>
<?php if ($_product->isAvailable()) :?>
<div class="stock available" title="<?= $block->escapeHtmlAttr(__('Availability')) ?>">
<span><?= $block->escapeHtml(__('In stock')) ?></span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()->
</button>
<?php endif; ?>
<?php else :?>
<?php if ($_item->getIsSalable()) :?>
<?php if ($_item->isAvailable()) :?>
<div class="stock available">
<span><?= $block->escapeHtml(__('In stock')) ?></span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()->
</button>
<?php endif; ?>
<?php else :?>
<?php if ($_item->getIsSalable()) :?>
<?php if ($_item->isAvailable()) :?>
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
<?php else :?>
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
</button>
</if>

<ifnot args="isSalable($row())">
<if args="isAvailable($row()) === false">
<div class="stock unavailable">
<text args="$t('Availability')"/>
<span translate="'Out of stock'"/>
</div>
</ifnot>
</if>
</if>
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ use Magento\Framework\App\Action\Action;
</button>
</form>
<?php else: ?>
<?php if ($_item->getIsSalable()): ?>
<?php if ($_item->isAvailable()): ?>
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
?>
<?php $_product = $block->getProduct() ?>

<?php if ($_product->getIsSalable()) : ?>
<?php if ($_product->isAvailable()) : ?>
<div class="stock available" title="<?= $block->escapeHtmlAttr(__('Availability')) ?>">
<span><?= $block->escapeHtml(__('In stock')) ?></span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ $rating = 'short';
</button>
<?php endif; ?>
<?php else : ?>
<?php if ($item->getIsSalable()) : ?>
<?php if ($item->isAvailable()) : ?>
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
<?php else : ?>
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ if ($exist = $block->getRecentlyComparedProducts()) {
<?php endif; ?>
</div>
<?php else : ?>
<?php if ($_product->getIsSalable()) : ?>
<?php if ($_product->isAvailable()) : ?>
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
<?php else : ?>
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ if ($exist = $block->getRecentlyComparedProducts()) {
</button>
<?php endif; ?>
<?php else : ?>
<?php if ($_item->getIsSalable()) : ?>
<?php if ($_item->isAvailable()) : ?>
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
<?php else : ?>
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if ($exist = $block->getRecentlyComparedProducts()) {
</button>
<?php endif; ?>
<?php else : ?>
<?php if ($_item->getIsSalable()) : ?>
<?php if ($_item->isAvailable()) : ?>
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
<?php else : ?>
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ if ($exist = ($block->getRecentlyViewedProducts() && $block->getRecentlyViewedPr
<?php endif; ?>
</div>
<?php else : ?>
<?php if ($_product->getIsSalable()) : ?>
<?php if ($_product->isAvailable()) : ?>
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
<?php else : ?>
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if ($exist = ($block->getRecentlyViewedProducts() && $block->getRecentlyViewedPr
</button>
<?php endif; ?>
<?php else : ?>
<?php if ($_item->getIsSalable()) : ?>
<?php if ($_item->isAvailable()) : ?>
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
<?php else : ?>
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ if ($exist = ($block->getRecentlyViewedProducts() && $block->getRecentlyViewedPr
</button>
<?php endif; ?>
<?php else : ?>
<?php if ($_item->getIsSalable()) : ?>
<?php if ($_item->isAvailable()) : ?>
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
<?php else : ?>
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ public function getMethodPrice($cost, $method = '')
'free_shipping_enable'
) && $this->getConfigData(
'free_shipping_subtotal'
) <= $this->_rawRequest->getBaseSubtotalInclTax() ? '0.00' : $this->getFinalPriceWithHandlingFee(
) <= $this->_rawRequest->getValueWithDiscount() ? '0.00' : $this->getFinalPriceWithHandlingFee(
$cost
);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Ups/Test/Unit/Model/CarrierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function testGetMethodPrice(
->willReturn($freeShippingEnabled);

$request = new RateRequest();
$request->setBaseSubtotalInclTax($requestSubtotal);
$request->setValueWithDiscount($requestSubtotal);
$this->model->setRawRequest($request);
$price = $this->model->getMethodPrice($cost, $shippingMethod);
$this->assertEquals($expectedPrice, $price);
Expand Down
Loading

0 comments on commit 1ba52ff

Please sign in to comment.