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