<?php /** @var \Autogedal\BlogInternalLinking\Block\Frontend\LinkingGroup $block */ use Magento\Framework\App\Action\Action; $group = $block->getGroup(); if (!$group): return; endif; $products = $block->getProducts(); $showSlider = $group->getShowSlider() && $products && count($products); $carouselId = 'blg-linking-carousel-' . $group->getId(); $_imagehelper = $this->helper('Magento\Catalog\Helper\Image'); $leadlionHelper = $this->helper('Leadlion\Autogedal\Helper\Config'); $_category_config = $this->helper('Smartwave\Porto\Helper\Data')->getConfig('porto_settings/category'); $image_width = ($_category_config['ratio_width']) ? $_category_config['ratio_width'] : 300; $image_height = ($_category_config['aspect_ratio']) ? $image_width : (($_category_config['ratio_height']) ? $_category_config['ratio_height'] : 300); ?> <div class="blog-linking-group"><div class="blog-linking-group__header"><h3 class="blog-linking-group__title"><?= $block->escapeHtml($group->getTitle()) ?></h3><?php if ($showSlider): ?> <div class="blg-carousel-nav"><button type="button" class="blg-prev" id="blg-prev-<?= (int)$group->getId() ?>"></button> <button type="button" class="blg-next" id="blg-next-<?= (int)$group->getId() ?>"></button></div><?php endif; ?></div><?php if ($showSlider): ?> <div class="blog-linking-group__carousel homepage-products"><div class="products wrapper grid products-grid"><div id="<?= $block->escapeHtmlAttr($carouselId) ?>" class="filterproducts products list items product-items owl-carousel"><?php foreach ($products as $_product): ?> <?php $qty = $leadlionHelper->getStockQty($_product, $_product->getStore()->getWebsiteId()); ?> <div class="item product product-item"><div class="product-item-info" data-container="product-grid"><div class="product photo product-item-photo"><a href="<?= $block->escapeUrl($_product->getProductUrl()) ?>" tabindex="-1"><?php if ($_category_config['aspect_ratio']) { $productImage = $_imagehelper->init($_product, 'category_page_grid') ->constrainOnly(false)->keepAspectRatio(true)->keepFrame(false) ->resize($image_width); } else { $productImage = $_imagehelper->init($_product, 'category_page_grid') ->resize($image_width, $image_height); } ?> <img class="product-image-photo default_image" src="<?= $block->escapeUrl($productImage->getUrl()) ?>" alt="<?= $block->escapeHtmlAttr($productImage->getLabel()) ?>" width="<?= (int)$image_width ?>" height="<?= (int)$image_height ?>" loading="lazy"/></a></div><div class="product details product-item-details"><strong class="product name product-item-name"><a class="product-item-link" href="<?= $block->escapeUrl($_product->getProductUrl()) ?>"><?= $block->escapeHtml($_product->getName()) ?></a></strong> <div class="product-sku-container"><span class="product sku_fz"><?php $attributeSetsIds = $leadlionHelper->getAttributesSetsIdsForShowingSku() ? explode(',', $leadlionHelper->getAttributesSetsIdsForShowingSku()) : []; if (in_array($_product->getAttributeSetId(), $attributeSetsIds)): ?> <?= $block->escapeHtml($_product->getSku()) ?> <?php else: ?> <?= $block->escapeHtml($_product->getSku_fz()) ?> <?php endif; ?></span></div><div class="rating-block"><?php $_ratingSummary = (int)$_product->getRatingSummary(); ?> <div class="product-reviews-summary short"><div class="rating-summary"><div class="rating-result" title="<?= $_ratingSummary ?>%"><span style="width:<?= $_ratingSummary ?>%;"></span></div></div></div></div><div class="product-stock"><?php if ($_product->isSaleable() && $_product->getIsSalable()): ?> <?php if ($qty > 0): ?> <div class="available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div><?php else: ?> <div class="unavailable"><span><?= $block->escapeHtml(__('To order')) ?></span></div><?php endif; ?> <?php else: ?> <div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div><?php endif; ?></div><div class="info-block"><?php if ($_product->getIsSalable() && $qty > 0): ?> <?php $termenLivrare = $_product->getTermenLivrare(); ?> <?php if ($termenLivrare): ?> <div class="product-term"><span><?= $block->escapeHtml(__('Fast shipping')) ?></span> <span class="term-value"><?= $block->escapeHtml($termenLivrare) ?></span></div><?php else: ?> <span><?= $block->escapeHtml(__('Fast shipping')) ?></span> <?php endif; ?> <?php elseif ($_product->getIsSalable()): ?> <span class="la-comanda"><?= $block->escapeHtml(__('Livrare 25-45 zile')) ?></span> <?php endif; ?></div><div class="action-price"><?= $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" action="<?= $block->escapeUrl($postParams['action']) ?>" method="post"><input type="hidden" name="product" value="<?= (int)$_product->getEntityId() ?>"><input type="hidden" name="<?= Action::PARAM_NAME_URL_ENCODED ?>" value="<?= $block->escapeHtmlAttr($postParams['data'][Action::PARAM_NAME_URL_ENCODED]) ?>"><?= $block->getBlockHtml('formkey') ?> <button type="submit" title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>" class="action tocart primary <?= $qty > 0 ? 'available' : 'unavailable' ?>"><span><?= __('Add to Cart') ?></span></button></form><?php else: ?> <div class="not-sal-product"><button class="action tocart primary unavailable" title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>"><span><?= __('Add to Cart') ?></span></button></div><?php endif; ?></div></div></div></div></div></div></div><?php endforeach; ?></div></div></div><script type="text/x-magento-init">
    {
        "[data-role=tocart-form]": {
            "catalogAddToCart": {}
        }
    }</script><script type="text/javascript">
    require(['jquery', 'owl.carousel/owl.carousel.min'], function ($) {
        var $carousel = $('#<?= $block->escapeJs($carouselId) ?>');
        $carousel.owlCarousel({
            loop: false,
            autoplay: false,
            margin: 16,
            nav: false,
            dots: false,
            responsive: {
                0:   { items: 1 },
                480: { items: 2 },
                768: { items: 3 },
                992: { items: 4 }
            }
        });
        $('#blg-prev-<?= (int)$group->getId() ?>').on('click', function () {
            $carousel.trigger('prev.owl.carousel');
        });
        $('#blg-next-<?= (int)$group->getId() ?>').on('click', function () {
            $carousel.trigger('next.owl.carousel');
        });
    });</script><?php endif; ?> <?php if (($group->getCtaUrl() && $group->getCtaText()) || ($group->getCtaUrl2() && $group->getCtaText2())): ?> <div class="blog-linking-group__cta"><?php if ($group->getCtaUrl() && $group->getCtaText()): ?> <a class="blog-linking-group__cta-btn action primary" href="<?= $block->escapeUrl($group->getCtaUrl()) ?>"><?= $block->escapeHtml($group->getCtaText()) ?></a> <?php endif; ?> <?php if ($group->getCtaUrl2() && $group->getCtaText2()): ?> <a class="blog-linking-group__cta-btn blog-linking-group__cta-btn--secondary action primary" href="<?= $block->escapeUrl($group->getCtaUrl2()) ?>"><?= $block->escapeHtml($group->getCtaText2()) ?></a> <?php endif; ?></div><?php endif; ?></div>