Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Magento\Framework\App\Action\Action;
- /**
- * Product list template
- *
- * @var $block \Magento\Catalog\Block\Product\ListProduct
- */
- ?>
- <?php
- $_productCollection = $block->getLoadedProductCollection();
- $_helper = $this->helper('Magento\Catalog\Helper\Output');
- ?>
- <?php if (!$_productCollection->count()): ?>
- <div class="message info empty"><div><?php /* @escapeNotVerified */ echo __('We can\'t find products matching the selection.') ?></div></div>
- <?php else: ?>
- <?php /* @escapeNotVerified */ echo $block->getToolbarHtml() ?>
- <?php /* @escapeNotVerified */ echo $block->getAdditionalHtml() ?>
- <?php
- if ($block->getMode() == 'grid') {
- $viewMode = 'grid';
- $image = 'category_page_grid';
- $showDescription = false;
- } else {
- $viewMode = 'list';
- $image = 'category_page_list';
- $showDescription = true;
- }
- //$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
- $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::FULL_VIEW;
- /**
- * Position for actions regarding image size changing in vde if needed
- */
- $pos = $block->getPositioned();
- ?>
- <div class="products wrapper <?php /* @escapeNotVerified */ echo $viewMode; ?> products-<?php /* @escapeNotVerified */ echo $viewMode; ?>">
- <?php $iterator = 1; ?>
- <ol class="products list items product-items">
- <?php /** @var $_product \Magento\Catalog\Model\Product */ ?>
- <?php foreach ($_productCollection as $_product): ?>
- <?php
- $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
- $StockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface');
- $qty = $StockState->getStockQty($_product->getId(), $_product->getStore()->getWebsiteId());
- $mode = "regular";
- $buttonLabel = "More info";
- if ($_product->getPrice() == 0 && $_product->getTypeId() == 'simple') {
- $mode = "info";
- }
- ?>
- <?php /* @escapeNotVerified */ echo $_product->getTitle() ?>
- <?php /* @escapeNotVerified */ echo($iterator++ == 1) ? '<li class="item product product-item">' : '</li><li class="item product product-item">' ?>
- <div class="product-item-info" data-container="product-grid">
- <?php
- $productImage = $block->getImage($_product, $image);
- if ($pos != null) {
- $position = ' style="left:' . $productImage->getWidth() . 'px;' . 'top:' . $productImage->getHeight() . 'px;"';
- }
- $_productNameStripped = $block->stripTags($_product->getName(), null, true);
- ?>
- <?php // Product Title ?>
- <strong class="product name product-item-name">
- <a class="product-item-link" href="<?php echo $_product->getProductUrl() ?>">
- <?php /* @escapeNotVerified */ echo strtoupper($_helper->productAttribute($_product, $_product->getName(), 'name')); ?>
- </a>
- </strong>
- <?php
- // loading the non cached image url
- $storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface');
- $currentStore = $storeManager->getStore();
- $baseMediaUrl = $currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
- $thumbUrl = $baseMediaUrl . 'catalog/product' . $_product->getImage();
- // check if image thumbnail exists
- $fileExists = (@fopen($thumbUrl, "r")) ? true : false;
- // if thumbnail not exists, we loadd the placeholder image
- if (!$fileExists) {
- $imageHelper = $objectManager->get('Magento\Catalog\Helper\Image');
- $thumbUrl = $imageHelper->getDefaultPlaceholderUrl('image');
- }
- ?>
- <?php // Product Image ?>
- <div class="sq-image">
- <a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">
- <?php /* @escapeNotVerified */ //echo $productImage->toHtml(); ?>
- <span class="product-image-container" style="width:240px;">
- <span class="product-image-wrapper" style="padding-bottom:125%;">
- <img class="product-image-photo" src="<?php echo $thumbUrl; ?>" alt="<?php echo $_product->getName(); ?>">
- </span>
- </span>
- </a>
- <?php
- // check for cf_1, cf_2, cf_3 custom attributes and if they existing show them in list item.
- $uspString = '<ul class="usp-ul">';
- if (!is_null($_product->getData('cf_1')) || $_product->getData('cf_1') != "") {
- $explode1 = explode(":", $_product->getData('cf_1'));
- $uspString .= '<li class="usp-li-class">' . $explode1[0] . "<strong>" . (count($explode1) > 1 ? ":" . $explode1[1] : '') . "</strong></li>";
- }
- if (!is_null($_product->getData('cf_2')) || $_product->getData('cf_2') != "") {
- $explode2 = explode(":", $_product->getData('cf_2'));
- $uspString .= '<li class="usp-li-class">' . $explode2[0] . "<strong>" . (count($explode2) > 1 ? ":" . $explode2[1] : '') . "</strong></li>";
- }
- if (!is_null($_product->getData('cf_3')) || $_product->getData('cf_3') != "") {
- $explode3 = explode(":", $_product->getData('cf_3'));
- $uspString .= '<li class="usp-li-class">' . $explode3[0] . "<strong>" . (count($explode3) > 1 ? ":" . $explode3[1] : '') . "</strong></li>";
- }
- $uspString .= "</ul>";
- $reviewSummary = $block->getReviewsSummaryHtml($_product, $templateType);
- ?>
- <?php processNone($qty, $_product); ?>
- </div>
- <?php $discounted = false; ?>
- <?php if ($_product->getSpecialPrice() != null): ?>
- <?php $discounted = true; ?>
- <div class="discount-price-tag">aanbieding!</div>
- <?php endif; ?>
- <div class="main-cont">
- <?php if ($reviewSummary != ""): ?>
- <div class="ratings-container">
- <?= $reviewSummary ?>
- </div>
- <?php endif; ?>
- <!-- showing the unique selling points -->
- <?php echo $uspString; ?>
- <a href="<?php echo $_product->getProductUrl() ?>">
- <div class="price-cart-main-container-list">
- <div class="price-container-list">
- <?php if ($_product->getIsSalable() || !$_product->getIsSalable()): ?>
- <!-- PRICE -->
- <div class="home_price_cart_group_fixed_height" <?php echo $mode == 'info' ? 'style="display:none;"' : ''; ?> >
- <div class="home_price_group">
- <div class="home_price"><?php /* @escapeNotVerified */ echo $block->getProductPrice($_product); ?></div>
- </div>
- </div>
- <!-- PRICE END -->
- <?php endif; ?>
- <!-- STOCK -->
- <div <?php echo $mode == 'info' ? 'style="display:none!important;"' : ''; ?> class="actions-primary"<?php echo strpos($pos, $viewMode . '-primary') ? $position : ''; ?>>
- <!-- IN STOCK -->
- <?php if ($_product->getIsSalable()): ?>
- <?php $_product->getData('expected_date') == null ? $expectedDate = "" : $expectedDate = $_product->getData('expected_date'); ?>
- <?php if (!$_product->getIsSalable() && $expectedDate != ""): ?>
- <p><font style="color: red; font-weight: bold">Niet Voorradig</font> Verwacht: <?php echo $expectedDate ?></p>
- <?php else: ?>
- <div class="home_in_stock"><?php /* @escapeNotVerified */ echo ($_product->getIsSalable() && $qty > 0) ? __("Morgen in huis") : __('In stock') ?></div>
- <?php endif; ?>
- <?php else: ?>
- <?php if ($_product->getData('expected_date') == null): ?>
- <div class="home_out_stock"><?php /* @escapeNotVerified */ echo __('Out of stock') ?></div>
- <?php else: ?>
- <?php //showing expected date message ?>
- <?php $_product->getData('expected_date') == null ? $expectedDate = "" : $expectedDate = $_product->getData('expected_date'); ?>
- <?php if ($expectedDate != ""): ?>
- <p><font style="color: red; font-weight: bold">Niet Voorradig</font> Verwacht: <?php echo $expectedDate ?></p>
- <?php endif; ?>
- <?php endif; ?>
- <?php endif; ?>
- <!-------------->
- </div>
- <!-- STOCK END -->
- </div>
- <div class="cart-container-list">
- <!-- ADD TO CART BUTTON -->
- <?php if ($_product->getIsSalable()): ?>
- <?php $postParams = $block->getAddToCartPostParams($_product); ?>
- <form data-role="tocart-form" action="<?php /* @escapeNotVerified */ echo $postParams['action']; ?>" method="post">
- <input type="hidden" name="product" value="<?php /* @escapeNotVerified */ echo $postParams['data']['product']; ?>">
- <input type="hidden" name="<?php /* @escapeNotVerified */ echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php /* @escapeNotVerified */ echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
- <?php /* @escapeNotVerified */ echo $block->getBlockHtml('formkey') ?>
- <?php if ($mode == "info"): ?>
- <button type="submit"
- style="display:none;"
- title="<?php /* @escapeNotVerified */ echo $block->escapeHtml(__('Add to cart')); ?>"
- class="action primary tocart home_cart_button">
- </button>
- <?php else: ?>
- <button type="submit"
- title="<?php /* @escapeNotVerified */ echo $block->escapeHtml(__('Add to cart')); ?>"
- class="action primary tocart home_cart_button">
- </button>
- <?php endif; ?>
- </form>
- <?php //showing the add to cart button even if out of stock but expected date is defined ?>
- <?php elseif (!$_product->isSaleable() && $_product->getData('expected_date') != null): ?>
- <button type="submit"
- title="<?php /* @escapeNotVerified */ echo $block->escapeHtml(__('Add to cart')); ?>"
- class="action primary tocart home_cart_button">
- </button>
- <?php endif; ?>
- <!-- ADD TO CART BUTTON ENDS -->
- </div>
- </div>
- </a>
- </div>
- </div>
- <?php echo($iterator == count($_productCollection) + 1) ? '</li>' : '' ?>
- <?php endforeach; ?>
- </ol>
- </div>
- <?php echo $block->getToolbarHtml() ?>
- <?php if (!$block->isRedirectToCartEnabled()) : ?>
- <div class="toolbar-bottom">
- <div class="toolbar bottom">
- <?php echo $block->getPagerHtml(); ?>
- </div>
- </div>
- <script type="text/x-magento-init">
- {
- "[data-role=tocart-form], .form.map.checkout": {
- "catalogAddToCart": {}
- }
- }
- </script>
- <?php endif; ?>
- <?php endif; ?>
- <?php
- function processNone($qty, $_product) {
- if ($qty > 0) {
- if ($_product->isSaleable()) {
- // stock is ok and sessable
- if (!is_null($_product->getData('delivery_48')) && $_product->getData('delivery_48') == "1" && $qty <= 0) {
- echo '<div class = "cataloglabel cataloglabel-product-top-label cataloglabel-fast-delivery cataloglabel-view position-BL" style = "background:url(\'https://misteragri-tech.eu/media/cataloglabel/u/n/untitled.jpg\'); background-repeat: no-repeat; width: 100px; height: 30px;">';
- echo '<span>Binnen 48 uur verzonden</span>';
- echo '</div>';
- return;
- } else {
- echo '<div class = "cataloglabel cataloglabel-product-top-label cataloglabel-fast-delivery cataloglabel-view position-BL" style = "background:url(\'https://misteragri-tech.eu/media/cataloglabel/u/n/untitled.jpg\'); background-repeat: no-repeat; width: 100px; height: 30px;">';
- echo '<span>Binnen 24 uur verzonden</span>';
- echo '</div>';
- return;
- }
- } else {
- // stock is ok but not sellable
- if (!is_null($_product->getData('expected_date'))) {
- $expectedDate = $_product->getData('expected_date');
- echo '<p><font style = "color: red; font-weight: bold">Niet Voorradig</font> Verwacht: ' . $expectedDate . '</p>';
- echo 'Dit product is tijdelijk niet leverbaar. U kunt hem wel bestellen maar de verwachte leverdatum is: ' . $expectedDate;
- return;
- } else {
- echo '<style type="text/css">.price-and-ratings{display: none!important;} .product-price-box{background-color: white; border: none;}</style>';
- echo '<span> <p class="product-ask-info-red">' . __('Tijdelijk niet leverbaar vraag voor meer informatie') . '</p></span>';
- return;
- }
- }
- } else {
- if ($_product->isSaleable()) {
- //stock is not ok but sellable
- if (!is_null($_product->getData('delivery_48')) && $_product->getData('delivery_48') == "1") {
- echo '<div class = "cataloglabel cataloglabel-product-top-label cataloglabel-fast-delivery cataloglabel-view position-BL" style = "background:url(\'https://misteragri-tech.eu/media/cataloglabel/u/n/untitled.jpg\'); background-repeat: no-repeat; width: 100px; height: 30px;">';
- echo '<span>Binnen 48 uur verzonden</span>';
- echo '</div>';
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement