Commit fecafbda by lmf

优化首页最新产品ID

parent 5384fe8a
...@@ -55,156 +55,42 @@ ...@@ -55,156 +55,42 @@
</div> </div>
</div> </div>
<?php
$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(',',"2246,2243,2199,1178,1125,1002");
//$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): <div class="flash_sale">
$product = $pr->getById($pid); <strong role="heading" aria-level="2" >NEW ARRIVALS</strong>
if(!$product) continue; <div class="flash-sale-wpt row" style="background: linear-gradient(to right, #ffffff, #ffffff);" >
$productImage = $imageHelper->init( $product, 'category_page_list' ) ->getUrl(); <div class="flash-sale-inner">
?> <?php
<li class="product-item"> $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
<div class="product-item-info"> $news_ids = explode(',',"2246,2243,2199,1178,1125,1002");
<a href="<?php echo $product->getProductUrl()?>" //$ids = explode(',',"1,2");
class="product-item-photo">
<?php //$block->getImage($_item, $image)->toHtml() ?> $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
<img src="<?php echo $productImage;?>" /></a> $pr = $objectManager->create('Magento\Catalog\Model\ProductRepository');
</a> $blocklist = $objectManager->get('\Magento\Catalog\Block\Product\ListProduct');
<div class="product-item-details"> $imageHelper = $objectManager->get( 'Magento\Catalog\Helper\Image' );
<strong class="product-item-name">
<a title="<?= $product->getName() ?>" foreach($ids as $pid):
href="<?php echo $product->getProductUrl()?>" $product = $pr->getById($pid);
class="product-item-link"> if(!$product) continue;
<?= $product->getName() ?> $productImage = $imageHelper->init( $product, 'category_page_list' ) ->getUrl();
</a> ?>
</strong> <div class="flash-sale-item">
<?= $blocklist->getReviewsSummaryHtml($product, $templateType) ?> <a href="<?php echo $product->getProductUrl()?>" >
<?= /* @noEscape */ $blocklist->getProductPrice($product) ?> <img src="<?php echo $productImage;?>" /></a>
</div> <div class="flash-sale-info">
</div> <a class="product-name" href="<?php echo $product->getProductUrl()?>"><?php echo $product->getName();?></a>
</li> <?= $blocklist->getReviewsSummaryHtml($product, $templateType) ?>
<?php endforeach ?> <?= /* @noEscape */ $blocklist->getProductPrice($product) ?>
</ol> </div>
</div>
<?php
endforeach;
?>
</div> </div>
</div> </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"> <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