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