Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
item.phtml
Go to the documentation of this file.
1 <?php
7 // @codingStandardsIgnoreFile
8 
9 /* @var $block \Magento\Reports\Block\Product\Widget\Viewed\Item */
10 ?>
11 
12 <?php
13 $type = $block->getType() . '-' . $block->getViewMode();
14 
15 $item = $block->getProduct();
16 
17 $image = $block->getImageType();
18 $rating = 'short';
19 ?>
20 <div class="block" id="widget_viewed_item" data-sku="<?= /* @escapeNotVerified */ $item->getSku() ?>" style="display: none;">
21  <li class="item product">
22  <div class="product">
23  <?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
24  <a href="<?= /* @escapeNotVerified */ $block->getProductUrl($item) ?>" class="product photo">
25  <?= $block->getImage($item, $image)->toHtml() ?>
26  </a>
27  <div class="product details">
28  <strong class="product name"><a title="<?= $block->escapeHtml($item->getName()) ?>" href="<?= /* @escapeNotVerified */ $block->getProductUrl($item) ?>">
29  <?= $block->escapeHtml($item->getName()) ?></a>
30  </strong>
31 
32  <?php /* @escapeNotVerified */ echo $block->getProductPriceHtml(
33  $item,
34  \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE,
35  \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST,
36  [
37  'price_id_suffix' => '-' . $type
38  ]
39  ) ?>
40 
41  <?php if ($rating): ?>
42  <?= $block->getReviewsSummaryHtml($item, $rating) ?>
43  <?php endif; ?>
44 
45  <div class="product actions">
46  <div class="primary">
47  <?php if ($item->isSaleable()): ?>
48  <?php if ($item->getTypeInstance()->hasRequiredOptions($item)): ?>
49  <button class="action tocart" data-mage-init='{"redirectUrl": {"url": "<?= /* @escapeNotVerified */ $block->getAddToCartUrl($item) ?>"}}' type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
50  <span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
51  </button>
52  <?php else: ?>
53  <?php $postDataHelper = $this->helper('Magento\Framework\Data\Helper\PostHelper');
54  $postData = $postDataHelper->getPostData($block->getAddToCartUrl($item), ['product' => $item->getEntityId()])
55  ?>
56  <button class="action tocart"
57  data-post='<?= /* @escapeNotVerified */ $postData ?>'
58  type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
59  <span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
60  </button>
61  <?php endif; ?>
62  <?php else: ?>
63  <?php if ($item->getIsSalable()): ?>
64  <div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
65  <?php else: ?>
66  <div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
67  <?php endif; ?>
68  <?php endif; ?>
69  </div>
70 
71  <div class="secondary-addto-links" data-role="add-to-links">
72  <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()): ?>
73  <a href="#" data-post='<?= /* @escapeNotVerified */ $block->getAddToWishlistParams($item) ?>' class="action towishlist" data-action="add-to-wishlist" title="<?= /* @escapeNotVerified */ __('Add to Wish List') ?>">
74  <span><?= /* @escapeNotVerified */ __('Add to Wish List') ?></span>
75  </a>
76  <?php endif; ?>
77  <?php if ($block->getAddToCompareUrl()): ?>
78  <?php
79  $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');
80  ?>
81  <a href="#" class="action tocompare"
82  data-post='<?= /* @escapeNotVerified */ $compareHelper->getPostDataParams($item) ?>'
83  data-role="add-to-links"
84  title="<?= /* @escapeNotVerified */ __('Add to Compare') ?>">
85  <span><?= /* @escapeNotVerified */ __('Add to Compare') ?></span>
86  </a>
87  <?php endif; ?>
88  </div>
89  </div>
90  </div>
91  </div>
92  </li>
93 </div>
if( $form)() ?>< script > require(['jquery' mage mage
Definition: save.phtml:15
__()
Definition: __.php:13
$rating
Definition: item.phtml:18
$block
Definition: block.php:8
endif
Definition: item.phtml:35
$item
Definition: item.phtml:15
$type
Definition: item.phtml:13
$image
Definition: item.phtml:17
$compareHelper
Definition: list.phtml:33