Commit 8d997d54 by lmf

优化首页最新款产品,改为手动推荐

parent 7cb63de8
......@@ -14,24 +14,14 @@
// phpcs:disable Magento2.Files.LineLength.MaxExceeded
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
if ($exist = ($block->getProductCollection() && $block->getProductCollection()->getSize())) {
$type = 'widget-new-grid';
$type = 'widget-new-grid';
$mode = 'grid';
$mode = 'grid';
$image = 'new_products_content_widget_grid';
$title = __('New Products');
$items = $block->getProductCollection()->getItems();
$showWishlist = false;
$showCompare = false;
$showCart = false;
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::DEFAULT_VIEW;
$description = false;
}
$image = 'new_products_content_widget_grid';
?>
<?php if ($exist) :?>
<div class="block widget block-new-products <?= /* @noEscape */ $mode ?>">
<div class="block-title">
<strong role="heading" aria-level="2" >NEW ARRIVALS</strong>
......@@ -40,32 +30,49 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()->
<?= /* @noEscape */ '<!-- ' . $image . '-->' ?>
<div class="products-<?= /* @noEscape */ $mode ?> <?= /* @noEscape */ $mode ?>">
<ol class="product-items <?= /* @noEscape */ $type ?>">
<?php foreach ($items as $_item) :?>
<?php
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
$news_ids = explode('366',"244,226,193");
//$news_ids = explode(',',"1,2");
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$pr = $objectManager->create('Magento\Catalog\Model\ProductRepository');
$blocklist = $objectManager->get('\Magento\Catalog\Block\Product\ListProduct');
$imageHelper = $objectManager->get( 'Magento\Catalog\Helper\Image' );
foreach($news_ids as $pid):
$product = $pr->getById($pid);
if(!$product) continue;
$productImage = $imageHelper->init( $product, 'category_page_list' ) ->getUrl();
?>
<li class="product-item">
<div class="product-item-info">
<a href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>"
<a href="<?php echo $product->getProductUrl()?>"
class="product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
<?php //$block->getImage($_item, $image)->toHtml() ?>
<img src="<?php echo $productImage;?>" /></a>
</a>
<div class="product-item-details">
<strong class="product-item-name">
<a title="<?= $block->escapeHtml($_item->getName()) ?>"
href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>"
<a title="<?= $product->getName() ?>"
href="<?php echo $product->getProductUrl()?>"
class="product-item-link">
<?= $block->escapeHtml($_item->getName()) ?>
<?= $product->getName() ?>
</a>
</strong>
<?= $block->getProductPriceHtml($_item); ?>
<?= $blocklist->getReviewsSummaryHtml($product, $templateType) ?>
<?= /* @noEscape */ $blocklist->getProductPrice($product) ?>
</div>
</div>
</li>
<?php endforeach ?>
</ol>
</div>
<?= $block->getPagerHtml() ?>
</div>
</div>
<?php endif;?>
<style>
.home-new-product{
width: 80%;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment