|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +use Magento\Framework\App\Action\Action; |
| 7 | + |
| 8 | +?> |
| 9 | +<?php |
| 10 | +/** |
| 11 | + * Product list template |
| 12 | + * |
| 13 | + * @var $block \Magento\Catalog\Block\Product\ListProduct |
| 14 | + * @var \Magento\Framework\Escaper $escaper |
| 15 | + * @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer |
| 16 | + */ |
| 17 | +?> |
| 18 | +<?php |
| 19 | +$_productCollection = $block->getLoadedProductCollection(); |
| 20 | +/** @var \Magento\Catalog\Helper\Output $_helper */ |
| 21 | +$_helper = $block->getData('outputHelper'); |
| 22 | +?> |
| 23 | +<?php if (!$_productCollection->count()): ?> |
| 24 | + <div class="message info empty"> |
| 25 | + <div><?= $escaper->escapeHtml(__('We can\'t find products matching the selection.')) ?></div> |
| 26 | + </div> |
| 27 | +<?php else: ?> |
| 28 | + <?= $block->getToolbarHtml() ?> |
| 29 | + <?= $block->getAdditionalHtml() ?> |
| 30 | + <?php |
| 31 | + if ($block->getMode() === 'grid') { |
| 32 | + $viewMode = 'grid'; |
| 33 | + $imageDisplayArea = 'category_page_grid'; |
| 34 | + $showDescription = false; |
| 35 | + $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW; |
| 36 | + } else { |
| 37 | + $viewMode = 'list'; |
| 38 | + $imageDisplayArea = 'category_page_list'; |
| 39 | + $showDescription = true; |
| 40 | + $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::FULL_VIEW; |
| 41 | + } |
| 42 | + /** |
| 43 | + * Position for actions regarding image size changing in vde if needed |
| 44 | + */ |
| 45 | + $pos = $block->getPositioned(); |
| 46 | + ?> |
| 47 | + <div class="products wrapper <?= /* @noEscape */ $viewMode ?> products-<?= /* @noEscape */ $viewMode ?>" |
| 48 | + data-template-override="React_React::product/list.phtml"> |
| 49 | + <ol class="products list items product-items"> |
| 50 | + <?php /** @var $_product \Magento\Catalog\Model\Product */ ?> |
| 51 | + <?php foreach ($_productCollection as $_product): ?> |
| 52 | + <?php |
| 53 | + // Ensure product URL is always valid and crawlable |
| 54 | + $productUrl = $_product->getProductUrl(); |
| 55 | + if (empty($productUrl) || $productUrl === '#') { |
| 56 | + $productUrl = $block->getUrl('catalog/product/view', ['id' => $_product->getId()]); |
| 57 | + } |
| 58 | + ?> |
| 59 | + <li class="item product product-item"> |
| 60 | + <div class="product-item-info" |
| 61 | + id="product-item-info_<?= /* @noEscape */ $_product->getId() ?>" |
| 62 | + data-container="product-<?= /* @noEscape */ $viewMode ?>"> |
| 63 | + <?php |
| 64 | + $productImage = $block->getImage($_product, $imageDisplayArea); |
| 65 | + if ($pos != null) { |
| 66 | + $position = 'left:' . $productImage->getWidth() . 'px;' |
| 67 | + . 'top:' . $productImage->getHeight() . 'px;'; |
| 68 | + } |
| 69 | + ?> |
| 70 | + <?php // Product Image ?> |
| 71 | + <a href="<?= $escaper->escapeUrl($productUrl) ?>" |
| 72 | + class="product photo product-item-photo" |
| 73 | + tabindex="-1"> |
| 74 | + <?= $productImage->toHtml() ?> |
| 75 | + </a> |
| 76 | + <div class="product details product-item-details"> |
| 77 | + <?php $_productNameStripped = $block->stripTags($_product->getName(), null, true); ?> |
| 78 | + <strong class="product name product-item-name"> |
| 79 | + <a class="product-item-link" |
| 80 | + href="<?= $escaper->escapeUrl($productUrl) ?>"> |
| 81 | + <?=/* @noEscape */ $_helper->productAttribute($_product, $_product->getName(), 'name')?> |
| 82 | + </a> |
| 83 | + </strong> |
| 84 | + <?= $block->getReviewsSummaryHtml($_product, $templateType) ?> |
| 85 | + <?= /* @noEscape */ $block->getProductPrice($_product) ?> |
| 86 | + |
| 87 | + <?= $block->getProductDetailsHtml($_product) ?> |
| 88 | + |
| 89 | + <div class="product-item-inner"> |
| 90 | + <div class="product actions product-item-actions"> |
| 91 | + <div class="actions-primary"> |
| 92 | + <?php if ($_product->isSaleable()):?> |
| 93 | + <?php $postParams = $block->getAddToCartPostParams($_product); ?> |
| 94 | + <form data-role="tocart-form" |
| 95 | + data-product-sku="<?= $escaper->escapeHtml($_product->getSku()) ?>" |
| 96 | + action="<?= $escaper->escapeUrl($postParams['action']) ?>" |
| 97 | + data-mage-init='{"catalogAddToCart": {}}' |
| 98 | + method="post"> |
| 99 | + <?php $options = $block->getData('viewModel')->getOptionsData($_product); ?> |
| 100 | + <?php foreach ($options as $optionItem): ?> |
| 101 | + <input type="hidden" |
| 102 | + name="<?= $escaper->escapeHtml($optionItem['name']) ?>" |
| 103 | + value="<?= $escaper->escapeHtml($optionItem['value']) ?>"> |
| 104 | + <?php endforeach; ?> |
| 105 | + <input type="hidden" |
| 106 | + name="product" |
| 107 | + value="<?= /* @noEscape */ $postParams['data']['product'] ?>"> |
| 108 | + <input type="hidden" |
| 109 | + name="<?= /* @noEscape */ Action::PARAM_NAME_URL_ENCODED ?>" |
| 110 | + value="<?= |
| 111 | + /* @noEscape */ $postParams['data'][Action::PARAM_NAME_URL_ENCODED] |
| 112 | + ?>"> |
| 113 | + <?= $block->getBlockHtml('formkey') ?> |
| 114 | + <button type="submit" |
| 115 | + title="<?= $escaper->escapeHtmlAttr(__('Add to Cart')) ?>" |
| 116 | + class="action tocart primary" |
| 117 | + disabled> |
| 118 | + <span><?= $escaper->escapeHtml(__('Add to Cart')) ?></span> |
| 119 | + </button> |
| 120 | + </form> |
| 121 | + <?php else:?> |
| 122 | + <?php if ($_product->isAvailable()):?> |
| 123 | + <div class="stock available"> |
| 124 | + <span><?= $escaper->escapeHtml(__('In stock')) ?></span></div> |
| 125 | + <?php else:?> |
| 126 | + <div class="stock unavailable"> |
| 127 | + <span><?= $escaper->escapeHtml(__('Out of stock')) ?></span></div> |
| 128 | + <?php endif; ?> |
| 129 | + <?php endif; ?> |
| 130 | + </div> |
| 131 | + <?= ($pos && strpos($pos, $viewMode . '-primary')) ? |
| 132 | + /* @noEscape */ $secureRenderer->renderStyleAsTag( |
| 133 | + $position, |
| 134 | + 'product-item-info_' . $_product->getId() . ' div.actions-primary' |
| 135 | + ) : '' ?> |
| 136 | + <div data-role="add-to-links" class="actions-secondary"> |
| 137 | + <?php if ($addToBlock = $block->getChildBlock('addto')): ?> |
| 138 | + <?= $addToBlock->setProduct($_product)->getChildHtml() ?> |
| 139 | + <?php endif; ?> |
| 140 | + </div> |
| 141 | + <?= ($pos && strpos($pos, $viewMode . '-secondary')) ? |
| 142 | + /* @noEscape */ $secureRenderer->renderStyleAsTag( |
| 143 | + $position, |
| 144 | + 'product-item-info_' . $_product->getId() . ' div.actions-secondary' |
| 145 | + ) : '' ?> |
| 146 | + </div> |
| 147 | + <?php if ($showDescription): ?> |
| 148 | + <div class="product description product-item-description"> |
| 149 | + <?= /* @noEscape */ $_helper->productAttribute( |
| 150 | + $_product, |
| 151 | + $_product->getShortDescription(), |
| 152 | + 'short_description' |
| 153 | + ) ?> |
| 154 | + <a href="<?= $escaper->escapeUrl($productUrl) ?>" |
| 155 | + title="<?= /* @noEscape */ $_productNameStripped ?>" |
| 156 | + class="action more"><?= $escaper->escapeHtml(__('Learn More')) ?></a> |
| 157 | + </div> |
| 158 | + <?php endif; ?> |
| 159 | + </div> |
| 160 | + </div> |
| 161 | + </div> |
| 162 | + <?= ($pos && strpos($pos, $viewMode . '-actions')) ? |
| 163 | + /* @noEscape */ $secureRenderer->renderStyleAsTag( |
| 164 | + $position, |
| 165 | + 'product-item-info_' . $_product->getId() . ' div.product-item-actions' |
| 166 | + ) : '' ?> |
| 167 | + </li> |
| 168 | + <?php endforeach; ?> |
| 169 | + </ol> |
| 170 | + </div> |
| 171 | + <?= $block->getChildBlock('toolbar')->setIsBottom(true)->toHtml() ?> |
| 172 | + <?php // phpcs:ignore Magento2.Legacy.PhtmlTemplate ?> |
| 173 | +<?php endif; ?> |
0 commit comments