Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
compared_grid.phtml
Go to the documentation of this file.
1 <?php
7 // @codingStandardsIgnoreFile
8 
9 ?>
10 
11 <?php
13 if ($exist = $block->getRecentlyComparedProducts()) {
14  $type = 'widget-compared';
15  $mode = 'grid';
16 
17  $type = $type . '-' . $mode;
18 
19  $image = 'recently_compared_products_grid_content_widget';
20  $title = __('Recently Compared');
21  $items = $exist;
22 
23  $showWishlist = true;
24  $showCompare = true;
25  $showCart = true;
26  $rating = 'short';
27  $description = ($mode == 'list') ? true : false;
28 }
29 ?>
30 
31 <?php if ($exist):?>
32  <div class="block widget block-compared-products-<?= /* @escapeNotVerified */ $mode ?>">
33  <div class="block-title">
34  <strong role="heading" aria-level="2"><?= /* @escapeNotVerified */ $title ?></strong>
35  </div>
36  <div class="block-content">
37  <?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
38  <div class="products-<?= /* @escapeNotVerified */ $mode ?> <?= /* @escapeNotVerified */ $mode ?>">
39  <ol class="product-items <?= /* @escapeNotVerified */ $type ?>">
40  <?php foreach ($items as $_item): ?>
41  <li class="product-item">
42  <div class="product-item-info">
43  <a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product-item-photo">
44  <?= $block->getImage($_item, $image)->toHtml() ?>
45  </a>
46  <div class="product-item-details">
47  <strong class="product-item-name">
48  <a title="<?= $block->escapeHtml($_item->getName()) ?>"
49  href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product-item-link">
50  <?= $block->escapeHtml($_item->getName()) ?>
51  </a>
52  </strong>
53  <?php /* @escapeNotVerified */ echo $block->getProductPriceHtml(
54  $_item,
55  \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE,
56  \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST,
57  [
58  'price_id_suffix' => '-' . $type
59  ]
60  ) ?>
61  <?php if ($rating): ?>
62  <?= $block->getReviewsSummaryHtml($_item, $rating) ?>
63  <?php endif; ?>
64  <?php if ($showWishlist || $showCompare || $showCart): ?>
65  <div class="product-item-actions">
66  <?php if ($showCart): ?>
67  <div class="actions-primary">
68  <?php if ($_item->isSaleable()): ?>
69  <?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
70  <button class="action tocart primary"
71  data-mage-init='{"redirectUrl": {"url": "<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_item) ?>"}}'
72  type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
73  <span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
74  </button>
75  <?php else: ?>
76  <?php
77  $postDataHelper = $this->helper('Magento\Framework\Data\Helper\PostHelper');
78  $postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
79  ?>
80  <button class="action tocart primary"
81  data-post='<?= /* @escapeNotVerified */ $postData ?>'
82  type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
83  <span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
84  </button>
85  <?php endif; ?>
86  <?php else: ?>
87  <?php if ($_item->getIsSalable()): ?>
88  <div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
89  <?php else: ?>
90  <div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
91  <?php endif; ?>
92  <?php endif; ?>
93  </div>
94  <?php endif; ?>
95 
96  <?php if ($showWishlist || $showCompare): ?>
97  <div class="actions-secondary" data-role="add-to-links">
98  <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow() && $showWishlist): ?>
99  <a href="#"
100  data-post='<?= /* @escapeNotVerified */ $block->getAddToWishlistParams($_item) ?>'
101  data-action="add-to-wishlist"
102  class="action towishlist"
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
$postData endif
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
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