Commit 96ce1820 by lmf

整合首页最新款文件

parent 6d0adc02
......@@ -57,7 +57,170 @@
</div>
<?php
echo $this->getLayout()->createBlock("Magento\Catalog\Block\Product\Widget\NewWidget")->setDisplayType("all_products")->setProductsCount("4")->setTemplate("product/widget/new/content/home_news_product.phtml")->toHtml(); ?>
/**
* Template for displaying new products widget
*
* @var $block \Magento\Catalog\Block\Product\Widget\NewWidget
*/
// phpcs:disable Magento2.Files.LineLength.MaxExceeded
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
$type = 'widget-new-grid';
$mode = 'grid';
$image = 'new_products_content_widget_grid';
?>
<div class="block widget block-new-products <?= /* @noEscape */ $mode ?>">
<div class="block-title">
<strong role="heading" aria-level="2" >NEW ARRIVALS</strong>
</div>
<div class="block-content home-new-product">
<?= /* @noEscape */ '<!-- ' . $image . '-->' ?>
<div class="products-<?= /* @noEscape */ $mode ?> <?= /* @noEscape */ $mode ?>">
<ol class="product-items <?= /* @noEscape */ $type ?>">
<?php
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
$news_ids = explode(',',"366,244,188,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="<?php echo $product->getProductUrl()?>"
class="product-item-photo">
<?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="<?= $product->getName() ?>"
href="<?php echo $product->getProductUrl()?>"
class="product-item-link">
<?= $product->getName() ?>
</a>
</strong>
<?= $blocklist->getReviewsSummaryHtml($product, $templateType) ?>
<?= /* @noEscape */ $blocklist->getProductPrice($product) ?>
</div>
</div>
</li>
<?php endforeach ?>
</ol>
</div>
</div>
</div>
<style>
.home-new-product{
width: 80%;
display: contents;
}
.block-title {
text-align: center;
font-size: x-large;
}
.actions-secondary a{
color: #000;
}
.product-item-name .product-item-link{
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
cursor: pointer;
width: 100%;
display: inline-block;
color: #222222;
}
.block-title > sto{
background: #fff;
font-size: 24px;
font-weight: bold;
color: #000000;
margin: 0px;
padding: 40px;
text-align: center;
}
.products-grid .product-items {
display: flex;
justify-content: space-around;
align-items: flex-end;
}
span.price-wrapper .price {
font-size: larger;
font-weight: 600;
}
.block .block-title strong:hover {
text-decoration: underline;
}
.block .block-title strong {
background: #fff;
font-size: 24px;
font-weight: bold !important;
color: #000000;
margin: 0px;
padding: 40px;
text-align: center;
}
button.action.tocart.primary {
background: #000;
}
ol.product-items.widget-new-grid{
padding: 5px;
margin-top: 30px;
margin-bottom: 30px;
}
.block-content.home-new-product{
display: contents;
}
@media (max-width: 789px){
li.product-item {
width: 100%;
max-width: 50%;
}
.grid {
display: list-item !important;
}
ol.product-items.widget-new-grid{
margin-top: 1px;
}
.block-title{
margin-top: -30px;
}
.block.widget.block-new-products.grid{
margin-top: -100px;
}
.product-item-actions {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
margin-top: -30px;
}
.block .block-title strong {
padding: 0px;
}
}
</style>
<div class="flash_sale">
......
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