Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
new_list.phtml
Go to the documentation of this file.
1 <?php
7 // @codingStandardsIgnoreFile
8 
9 ?>
10 <?php
16 if ($exist = ($block->getProductCollection() && $block->getProductCollection()->getSize())) {
17  $type = 'widget-new-list';
18 
19  $mode = 'list';
20 
21  $image = 'new_products_content_widget_list';
22  $title = __('New Products');
23  $items = $block->getProductCollection()->getItems();
24  $_helper = $this->helper('Magento\Catalog\Helper\Output');
25 
26  $showWishlist = true;
27  $showCompare = true;
28  $showCart = true;
30  $description = true;
31 }
32 ?>
33 
34 <?php if ($exist):?>
35  <div class="block widget block-new-products <?= /* @escapeNotVerified */ $mode ?>">
36  <div class="block-title">
37  <strong role="heading" aria-level="2"><?= /* @escapeNotVerified */ $title ?></strong>
38  </div>
39  <div class="block-content">
40  <?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
41  <div class="products-<?= /* @escapeNotVerified */ $mode ?> <?= /* @escapeNotVerified */ $mode ?>">
42  <ol class="product-items <?= /* @escapeNotVerified */ $type ?>">
43  <?php foreach ($items as $_item): ?>
44  <li class="product-item">
45  <div class="product-item-info">
46  <a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product-item-photo">
47  <?= $block->getImage($_item, $image)->toHtml() ?>
48  </a>
49  <div class="product-item-details">
50  <strong class="product-item-name">
51  <a title="<?= $block->escapeHtml($_item->getName()) ?>"
52  href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>"
53  class="product-item-link">
54  <?= $block->escapeHtml($_item->getName()) ?>
55  </a>
56  </strong>
57  <?= $block->getProductPriceHtml($_item, $type) ?>
58 
59  <?php if ($templateType): ?>
60  <?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
61  <?php endif; ?>
62 
63  <?php if ($showWishlist || $showCompare || $showCart): ?>
64  <div class="product-item-actions">
65  <?php if ($showCart): ?>
66  <div class="actions-primary">
67  <?php if ($_item->isSaleable()): ?>
68  <?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
69  <button class="action tocart primary"
70  data-mage-init='{"redirectUrl":{"url":"<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_item) ?>"}}'
71  type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
72  <span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
73  </button>
74  <?php else: ?>
75  <?php
76  $postDataHelper = $this->helper('Magento\Framework\Data\Helper\PostHelper');
77  $postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
78  ?>
79  <button class="action tocart primary"
80  data-post='<?= /* @escapeNotVerified */ $postData ?>'
81  type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
82  <span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
83  </button>
84  <?php endif; ?>
85  <?php else: ?>
86  <?php if ($_item->getIsSalable()): ?>
87  <div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
88  <?php else: ?>
89  <div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
90  <?php endif; ?>
91  <?php endif; ?>
92  </div>
93  <?php endif; ?>
94  <?php if ($showWishlist || $showCompare): ?>
95  <div class="actions-secondary" data-role="add-to-links">
96  <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow() && $showWishlist): ?>
97  <a href="#"
98  data-post='<?= /* @escapeNotVerified */ $block->getAddToWishlistParams($_item) ?>'
99  class="action towishlist" data-action="add-to-wishlist"
100  title="<?= /* @escapeNotVerified */ __('Add to Wish List') ?>">
101  <span><?= /* @escapeNotVerified */ __('Add to Wish List') ?></span>
102  </a>
103  <?php endif; ?>
104  <?php if ($block->getAddToCompareUrl() && $showCompare): ?>
105  <?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare'); ?>
106  <a href="#" class="action tocompare"
107  title="<?= /* @escapeNotVerified */ __('Add to Compare') ?>"
108  data-post='<?= /* @escapeNotVerified */ $compareHelper->getPostDataParams($_item) ?>'>
109  <span><?= /* @escapeNotVerified */ __('Add to Compare') ?></span>
110  </a>
111  <?php endif; ?>
112  </div>
113  <?php endif; ?>
114  </div>
115  <?php endif; ?>
116  <?php if ($description):?>
117  <div class="product-item-description">
118  <?= /* @escapeNotVerified */ $_helper->productAttribute($_item, $_item->getShortDescription(), 'short_description') ?>
119  <a title="<?= $block->escapeHtml($_item->getName()) ?>"
120  href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>"
121  class="action more"><?= /* @escapeNotVerified */ __('Learn More') ?></a>
122  </div>
123  <?php endif; ?>
124  </div>
125  </div>
126  </li>
127  <?php endforeach ?>
128  </ol>
129  </div>
130  <?= $block->getPagerHtml() ?>
131  </div>
132  </div>
133 <?php endif;?>
$title
Definition: default.phtml:14
foreach( $this->main as $item) endforeach
Definition: side-menu.phtml:10
if( $form)() ?>< script > require(['jquery' mage mage
Definition: save.phtml:15
__()
Definition: __.php:13
$templateType
Definition: list.phtml:37
$block
Definition: block.php:8
$type
Definition: item.phtml:13
$showCompare
Definition: grid.phtml:21
$_item
Definition: default.phtml:11
$_helper
Definition: image.phtml:18
$postData endif
Definition: new_list.phtml:82
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
$compareHelper
Definition: list.phtml:33
$showCart
Definition: grid.phtml:22
$showWishlist
Definition: grid.phtml:20
$items