I’m on magento 2.4.5
I want to put requisition list dropdown on homepage, like he appears when we search for any product, with a clickable icon
My file list. phtml vendor/magento/module-catalog/view/frontend/templates/product/list.phtml
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use MagentoFrameworkAppActionAction;
?>
<?php
/**
* Product list template
*
* @var $block MagentoCatalogBlockProductListProduct
* @var MagentoFrameworkEscaper $escaper
* @var MagentoFrameworkViewHelperSecureHtmlRenderer $secureRenderer
*/
?>
<?php
$_productCollection = $block->getLoadedProductCollection();
/** @var MagentoCatalogHelperOutput $_helper */
$_helper = $block->getData('outputHelper');
?>
<?php if (!$_productCollection->count()): ?>
<div class="message info empty">
<div><?= $escaper->escapeHtml(__('We can't find products matching the selection.')) ?></div>
</div>
<?php else: ?>
<?= $block->getToolbarHtml() ?>
<?= $block->getAdditionalHtml() ?>
<?php
if ($block->getMode() === 'grid') {
$viewMode = 'grid';
$imageDisplayArea = 'category_page_grid';
$showDescription = false;
$templateType = MagentoCatalogBlockProductReviewRendererInterface::SHORT_VIEW;
} else {
$viewMode = 'list';
$imageDisplayArea = 'category_page_list';
$showDescription = true;
$templateType = MagentoCatalogBlockProductReviewRendererInterface::FULL_VIEW;
}
/**
* Position for actions regarding image size changing in vde if needed
*/
$pos = $block->getPositioned();
?>
<div class="products wrapper <?= /* @noEscape */ $viewMode ?> products-<?= /* @noEscape */ $viewMode ?>">
<ol class="products list items product-items">
<?php /** @var $_product MagentoCatalogModelProduct */ ?>
<?php foreach ($_productCollection as $_product): ?>
<li class="item product product-item">
<div class="product-item-info"
id="product-item-info_<?= /* @noEscape */ $_product->getId() ?>"
data-container="product-<?= /* @noEscape */ $viewMode ?>">
<?php
$productImage = $block->getImage($_product, $imageDisplayArea);
if ($pos != null) {
$position = 'left:' . $productImage->getWidth() . 'px;'
. 'top:' . $productImage->getHeight() . 'px;';
}
?>
<?php // Product Image ?>
<a href="<?= $escaper->escapeUrl($_product->getProductUrl()) ?>"
class="product photo product-item-photo"
tabindex="-1">
<?= $productImage->toHtml() ?>
</a>
<div class="product details product-item-details">
<?php $_productNameStripped = $block->stripTags($_product->getName(), null, true); ?>
<strong class="product name product-item-name">
<a class="product-item-link"
href="<?= $escaper->escapeUrl($_product->getProductUrl()) ?>">
<?=/* @noEscape */ $_helper->productAttribute($_product, $_product->getName(), 'name')?>
</a>
</strong>
<?= $block->getReviewsSummaryHtml($_product, $templateType) ?>
<?= /* @noEscape */ $block->getProductPrice($_product) ?>
<?= $block->getProductDetailsHtml($_product) ?>
<div class="product-item-inner">
<div class="product actions product-item-actions">
<div class="actions-primary">
<?php if ($_product->isSaleable()):?>
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
<form data-role="tocart-form"
data-product-sku="<?= $escaper->escapeHtml($_product->getSku()) ?>"
action="<?= $escaper->escapeUrl($postParams['action']) ?>"
method="post">
<?php $options = $block->getData('viewModel')->getOptionsData($_product); ?>
<?php foreach ($options as $optionItem): ?>
<input type="hidden"
name="<?= $escaper->escapeHtml($optionItem['name']) ?>"
value="<?= $escaper->escapeHtml($optionItem['value']) ?>">
<?php endforeach; ?>
<input type="hidden"
name="product"
value="<?= /* @noEscape */ $postParams['data']['product'] ?>">
<input type="hidden"
name="<?= /* @noEscape */ Action::PARAM_NAME_URL_ENCODED ?>"
value="<?=
/* @noEscape */ $postParams['data'][Action::PARAM_NAME_URL_ENCODED]
?>">
<?= $block->getBlockHtml('formkey') ?>
<button type="submit"
title="<?= $escaper->escapeHtmlAttr(__('Add to Cart')) ?>"
class="action tocart primary"
disabled>
<span><?= $escaper->escapeHtml(__('Add to Cart')) ?></span>
</button>
</form>
<?php else:?>
<?php if ($_product->isAvailable()):?>
<div class="stock available">
<span><?= $escaper->escapeHtml(__('In stock')) ?></span></div>
<?php else:?>
<div class="stock unavailable">
<span><?= $escaper->escapeHtml(__('Out of stock')) ?></span></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?= ($pos && strpos($pos, $viewMode . '-primary')) ?
/* @noEscape */ $secureRenderer->renderStyleAsTag(
$position,
'product-item-info_' . $_product->getId() . ' div.actions-primary'
) : '' ?>
<div data-role="add-to-links" class="actions-secondary">
<?php if ($addToBlock = $block->getChildBlock('addto')): ?>
<?= $addToBlock->setProduct($_product)->getChildHtml() ?>
<?php endif; ?>
</div>
<?= ($pos && strpos($pos, $viewMode . '-secondary')) ?
/* @noEscape */ $secureRenderer->renderStyleAsTag(
$position,
'product-item-info_' . $_product->getId() . ' div.actions-secondary'
) : '' ?>
</div>
<?php if ($showDescription): ?>
<div class="product description product-item-description">
<?= /* @noEscape */ $_helper->productAttribute(
$_product,
$_product->getShortDescription(),
'short_description'
) ?>
<a href="<?= $escaper->escapeUrl($_product->getProductUrl()) ?>"
title="<?= /* @noEscape */ $_productNameStripped ?>"
class="action more"><?= $escaper->escapeHtml(__('Learn More')) ?></a>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?= ($pos && strpos($pos, $viewMode . '-actions')) ?
/* @noEscape */ $secureRenderer->renderStyleAsTag(
$position,
'product-item-info_' . $_product->getId() . ' div.product-item-actions'
) : '' ?>
</li>
<?php endforeach; ?>
</ol>
</div>
<?= $block->getChildBlock('toolbar')->setIsBottom(true)->toHtml() ?>
<?php // phpcs:ignore Magento2.Legacy.PhtmlTemplate ?>
<script type="text/x-magento-init">
{
"[data-role=tocart-form], .form.map.checkout": {
"catalogAddToCart": {
"product_sku": "<?= $escaper->escapeJs($_product->getSku()) ?>"
}
}
}
</script>
<?php endif; ?>
my file grid.phtml /app/design/frontend/Madeiranit/base/Magento_CatalogWidget/templates/product/widget/content/grid.phtml
<?php use MagentoFrameworkPricingHelperData;
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use MagentoFrameworkAppActionAction;
/** @var MagentoCatalogWidgetBlockProductProductsList $block */
?>
<?php if ($exist = ($block->getProductCollection() && $block->getProductCollection()->getSize())) : ?>
<?php
$type = 'widget-product-grid';
$mode = 'grid';
$image = 'new_products_content_widget_grid';
$items = $block->getProductCollection()->getItems();
$showWishlist = true;
$showCompare = true;
$showCart = true;
$templateType = MagentoCatalogBlockProductReviewRendererInterface::SHORT_VIEW;
$description = false;
?>
<div class="block widget block-products-list <?= /* @noEscape */ $mode ?>">
<?php if ($block->getTitle()) : ?>
<div class="block-title">
<strong><?= $block->escapeHtml(__($block->getTitle())) ?></strong>
</div>
<?php endif ?>
<div class="block-content">
<?= /* @noEscape */ '<!-- ' . $image . '-->' ?>
<div class="products-<?= /* @noEscape */ $mode ?> <?= /* @noEscape */ $mode ?>">
<ol class="product-items <?= /* @noEscape */ $type ?>">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item) : ?>
<?= /* @noEscape */ ($iterator++ == 1) ?
'<li class="product-item">' :
'</li><li class="product-item">' ?>
<div class="product-item-info">
<a href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>"
class="product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
<div class="product-item-details">
<strong class="product-item-name">
<a title="<?= $block->escapeHtml($_item->getName()) ?>"
href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>"
class="product-item-link">
<?= $block->escapeHtml($_item->getName()) ?>
</a>
</strong>
<div class="yv-review-quickreview" value="<?= $_item->getId() ?>>"></div>
<?= $block->getProductPriceHtml($_item, $type) ?>
<?= $block->getProductDetailsHtml($_item) ?>
<?php if ($showWishlist || $showCompare || $showCart) : ?>
<div class="product-item-inner">
<div class="product-item-actions">
<?php if ($showCart) : ?>
<div class="actions-primary">
<?php if ($_item->isSaleable()) : ?>
<?php $postParams = $block->getAddToCartPostParams($_item); ?>
<form
data-role="tocart-form"
data-product-sku="<?=$block->escapeHtml($_item->getSku())?>"
action="<?= $block->escapeUrl($postParams['action']) ?>"
method="post">
<input
type="hidden"
name="product"
value="<?=
$block->escapeHtmlAttr($postParams['data']['product'])
?>">
<input
type="hidden"
name="<?= /* @noEscape */
Action::PARAM_NAME_URL_ENCODED ?>"
value="<?= /* @noEscape */
$postParams['data'][Action::PARAM_NAME_URL_ENCODED]?>">
<?= $block->getBlockHtml('formkey') ?>
<div class="field qty">
<div class="control">
<button type="button" class="action-qty js-minus"
data-qty="minus">-</button>
<input type="number"
name="qty"
min="0"
value="1"
title="<?= $block->escapeHtmlAttr(__('Qty'))?>"
class="input-text qty"
/>
<button type="button"
class="action-qty js-plus" data-qty="plus">+
</button>
</div>
</div>
<button type="submit"
title="<?= $block->escapeHtml(__('Add to Cart')) ?>"
class="action tocart primary">
<span>
<?= $block->escapeHtml(__('Add to Cart')) ?>
</span>
</button>
</form>
<?php else : ?>
<?php if ($_item->getIsSalable()) : ?>
<div class="stock available"><span>
<?= $block->escapeHtml(__('In stock')) ?>
</span></div>
<?php else : ?>
<div class="stock unavailable"><span>
<?= $block->escapeHtml(__('Out of stock')) ?>
</span></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="actions-secondary" data-role="add-to-links">
<?php if ($this->helper(MagentoWishlistHelperData::class)->isAllow()
&& $showWishlist) : ?>
<a href="#"
data-post="<?= /* @noEscape */
$block->getAddToWishlistParams($_item) ?>"
class="action towishlist" data-action="add-to-wishlist"
title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>">
<span><?= $block->escapeHtml(__('Add to Wish List')) ?></span>
<i class="icon-heart"></i>
</a>
<?php endif; ?>
<?php if ($block->getAddToCompareUrl() && $showCompare) : ?>
<?php $compareHelper =
$this->helper(MagentoCatalogHelperProductCompare::class);?>
<a href="#" class="action tocompare"
data-post="<?= /* @noEscape */
$compareHelper->getPostDataParams($_item) ?>"
title="<?= $block->escapeHtmlAttr(__('Add to Compare')) ?>">
<span><?= $block->escapeHtml(__('Add to Compare')) ?></span>
</a>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "Product",
"name" : "<?= $_item->getName() ?>",
"image" : "<?= $block->getImage($_item, $image)->getImageUrl() ?>",
"description" : "<?php if ($_item->getDescription()) {
strip_tags($_item->getDescription());
} else {
$_item->getDescription();
} ?>",
"url" : "",
"offers" : {
"@type" : "Offer",
"price" : "<?= $_item->getFinalPrice() ?>"
}
}
</script>
<?= ($iterator == count($items) + 1) ? '</li>' : '' ?>
<?php endforeach ?>
</ol>
</div>
<?= $block->getPagerHtml() ?>
</div>
</div>
<?php if (!$block->isRedirectToCartEnabled()) :?>
<script type="text/x-magento-init">
{
"[data-role=tocart-form], .form.map.checkout": {
"catalogAddToCart": {
"product_sku": "<?= $block->escapeJs($_item->getSku()) ?>"
}
}
}
</script>
<?php endif; ?>
<?php endif;?>