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