Skip to content

9787-fix-product-name #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions Magento_CatalogWidget/templates/product/widget/content/grid.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

use Magento\Framework\App\Action\Action;

/** @var \Magento\CatalogWidget\Block\Product\ProductsList $block */

// phpcs:disable Generic.Files.LineLength.TooLong
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundHelper
?>
<?php if ($exist = ($block->getProductCollection() && $block->getProductCollection()->getSize())): ?>
<?php
$type = 'widget-product-grid';

$mode = 'grid';

$image = 'new_products_content_widget_grid';
$items = $block->getProductCollection()->getItems();

$showWishlist = true;
$showCompare = true;
$showCart = true;
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
$description = false;
?>
<div class="block widget block-products-list <?= /* @noEscape */ $mode ?>">
<?php if ($block->getTitle()): ?>
<div class="block-title">
<strong><?= $block->escapeHtml(__($block->getTitle())) ?></strong>
</div>
<?php endif ?>
<div class="block-content">
<?= /* @noEscape */ '<!-- ' . $image . '-->' ?>
<div class="products-<?= /* @noEscape */ $mode ?> <?= /* @noEscape */ $mode ?>">
<ol class="product-items <?= /* @noEscape */ $type ?>">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item): ?>
<?= /* @noEscape */ ($iterator++ == 1) ? '<li class="product-item">' : '</li><li class="product-item">' ?>
<div class="product-item-info">
<a href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>" class="product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
<div class="product-item-details">
<strong class="product-item-name">
<a title="<?= $block->escapeHtml($_item->getName()) ?>"
href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>"
class="product-item-link">
<?= $block->escapeHtml($_item->getName()) ?>
</a>
</strong>
<?php if (true || $templateType): ?>
<?= $block->getReviewsSummaryHtml($_item, $templateType, true) ?>
<?php endif; ?>

<?= $block->getProductPriceHtml($_item, $type) ?>

<?= $block->getProductDetailsHtml($_item) ?>

<?php if ($showWishlist || $showCompare || $showCart): ?>
<div class="product-item-inner">
<div class="product-item-actions">
<?php if ($showCart): ?>
<div class="actions-primary">
<?php if ($_item->isSaleable()): ?>
<?php $postParams = $block->getAddToCartPostParams($_item); ?>
<form data-role="tocart-form" data-product-sku="<?= $block->escapeHtml($_item->getSku()) ?>" action="<?= $block->escapeUrl($postParams['action']) ?>" method="post">
<input type="hidden" name="product" value="<?= $block->escapeHtmlAttr($postParams['data']['product']) ?>">
<input type="hidden" name="<?= /* @noEscape */ Action::PARAM_NAME_URL_ENCODED ?>" value="<?= /* @noEscape */ $postParams['data'][Action::PARAM_NAME_URL_ENCODED] ?>">
<?= $block->getBlockHtml('formkey') ?>
<button type="submit"
title="<?= $block->escapeHtml(__('Add to Cart')) ?>"
class="action tocart primary">
<span><?= $block->escapeHtml(__('Add to Cart')) ?></span>
</button>
</form>
<?php else: ?>
<?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>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($showWishlist || $showCompare): ?>
<div class="actions-secondary" data-role="add-to-links">
<?php if ($this->helper(\Magento\Wishlist\Helper\Data::class)->isAllow() && $showWishlist): ?>
<a href="#"
data-post='<?= /* @noEscape */ $block->getAddToWishlistParams($_item) ?>' class="action towishlist" data-action="add-to-wishlist" title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>">
<span><?= $block->escapeHtml(__('Add to Wish List')) ?></span>
</a>
<?php endif; ?>
<?php if ($block->getAddToCompareUrl() && $showCompare): ?>
<?php $compareHelper = $this->helper(\Magento\Catalog\Helper\Product\Compare::class);?>
<a href="#" class="action tocompare" data-post='<?= /* @noEscape */ $compareHelper->getPostDataParams($_item) ?>' title="<?= $block->escapeHtmlAttr(__('Add to Compare')) ?>">
<span><?= $block->escapeHtml(__('Add to Compare')) ?></span>
</a>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?= ($iterator == count($items) + 1) ? '</li>' : '' ?>
<?php endforeach ?>
</ol>
</div>
<?= $block->getPagerHtml() ?>
</div>
</div>
<?php if($block->getBlockHtml('formkey')): ?>
<script type="text/x-magento-init">
{
".block.widget [data-role=tocart-form]": {
"Magento_Catalog/js/validate-product": {}
}
}
</script>
<?php endif;?>
<?php endif;?>
64 changes: 64 additions & 0 deletions Magento_Review/templates/helper/summary_short.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

/** @var \Magento\Review\Block\Product\ReviewRenderer $block */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */

$url = $block->getReviewsUrl() . '#reviews';
$urlForm = $block->getReviewsUrl() . '#review-form';

$displayIfEmpty = $block->getDisplayIfEmpty();
$listPage = in_array($block->getRequest()->getFullActionName(), ['cms_index_index', 'catalogsearch_result_index', 'catalog_category_view']);

if ($listPage) {
$displayIfEmpty = true;
}
//if ($block->getRequest()->getActionName())

?>
<?php if ($block->isReviewEnabled() && $block->getReviewsCount()): ?>
<?php $rating = $block->getRatingSummary(); ?>
<div class="product-reviews-summary short<?= !$rating ? ' no-rating' : '' ?>">
<?php if ($rating):?>
<div class="rating-summary">
<span class="label"><span><?= $block->escapeHtml(__('Rating')) ?>:</span></span>
<div class="rating-result"
id="rating-result_<?= /* @noEscape */ $block->getProduct()->getId() ?>"
title="<?= $block->escapeHtmlAttr($rating) ?>%">
<span><span><?= $block->escapeHtml($rating) ?>%</span></span>
</div>
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
'width:' . $block->escapeHtmlAttr($rating) . '%',
'#rating-result_' . $block->getProduct()->getId() . ' span'
) ?>
</div>
<?php endif;?>
<div class="reviews-actions">
<a class="action view"
href="<?= $block->escapeUrl($url) ?>"><?= $block->escapeHtml($block->getReviewsCount()) ?>
&nbsp;<span><?= ($block->getReviewsCount() == 1) ?
$block->escapeHtml(__('Review')) : $block->escapeHtml(__('Reviews')) ?>
</span>
</a>
</div>
</div>
<?php elseif ($block->isReviewEnabled() && $displayIfEmpty): ?>
<div class="product-reviews-summary short empty">
<div class="rating-summary">
<div class="rating-result"></div>
</div>
<div class="reviews-actions">
<?php if ($listPage) { ?>
<span></span>
<?php } else { ?>
<a class="action add" href="<?= $block->escapeUrl($urlForm) ?>">
<?= $block->escapeHtml(__('Be the first to review this product')) ?>
</a>
<?php } ?>
</div>
</div>
<?php endif; ?>

30 changes: 24 additions & 6 deletions web/css/source/_extend.less
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ input:-webkit-autofill:active {
.product-item-actions {
flex-grow: 1;
//margin-top: auto;
margin-top: 15px;
margin-top: 5px;
margin-bottom: 0;
}
.product-item-description {
Expand Down Expand Up @@ -412,6 +412,10 @@ input:-webkit-autofill:active {
box-sizing: border-box;
.product-item-name {
margin: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
.product-item-link {}
}
.price-box {
margin: 0 0 5px 0;
Expand All @@ -434,11 +438,25 @@ input:-webkit-autofill:active {
}

// Summary
.product-reviews-summary {
margin-bottom: 10px;
.reviews-actions {
a {
color: @theme__color__secondary;
& when (@media-common = true) {
.product-reviews-summary {

&.short.empty {
.rating-summary {
.rating-result {
position: relative;
height: 28px;
&:before {
opacity: 0.5;
}
}
}
}

.reviews-actions {
a {
color: @theme__color__secondary;
}
}
}
}
Expand Down