Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.78 KB | None | 0 0
  1. <?php
  2.  
  3. use Magento\Framework\App\Action\Action;
  4.  
  5. /**
  6. * Product list template
  7. *
  8. * @var $block \Magento\Catalog\Block\Product\ListProduct
  9. */
  10. ?>
  11. <?php
  12. $_productCollection = $block->getLoadedProductCollection();
  13. $_helper = $this->helper('Magento\Catalog\Helper\Output');
  14. ?>
  15. <?php if (!$_productCollection->count()): ?>
  16. <div class="message info empty"><div><?php /* @escapeNotVerified */ echo __('We can\'t find products matching the selection.') ?></div></div>
  17. <?php else: ?>
  18. <?php /* @escapeNotVerified */ echo $block->getToolbarHtml() ?>
  19. <?php /* @escapeNotVerified */ echo $block->getAdditionalHtml() ?>
  20. <?php
  21. if ($block->getMode() == 'grid') {
  22. $viewMode = 'grid';
  23. $image = 'category_page_grid';
  24. $showDescription = false;
  25. } else {
  26. $viewMode = 'list';
  27. $image = 'category_page_list';
  28. $showDescription = true;
  29. }
  30.  
  31. //$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
  32. $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::FULL_VIEW;
  33.  
  34. /**
  35. * Position for actions regarding image size changing in vde if needed
  36. */
  37. $pos = $block->getPositioned();
  38. ?>
  39. <div class="products wrapper <?php /* @escapeNotVerified */ echo $viewMode; ?> products-<?php /* @escapeNotVerified */ echo $viewMode; ?>">
  40. <?php $iterator = 1; ?>
  41. <ol class="products list items product-items">
  42. <?php /** @var $_product \Magento\Catalog\Model\Product */ ?>
  43. <?php foreach ($_productCollection as $_product): ?>
  44. <?php
  45. $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
  46. $StockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface');
  47. $qty = $StockState->getStockQty($_product->getId(), $_product->getStore()->getWebsiteId());
  48.  
  49. $mode = "regular";
  50. $buttonLabel = "More info";
  51.  
  52. if ($_product->getPrice() == 0 && $_product->getTypeId() == 'simple') {
  53. $mode = "info";
  54. }
  55. ?>
  56.  
  57. <?php /* @escapeNotVerified */ echo $_product->getTitle() ?>
  58. <?php /* @escapeNotVerified */ echo($iterator++ == 1) ? '<li class="item product product-item">' : '</li><li class="item product product-item">' ?>
  59.  
  60. <div class="product-item-info" data-container="product-grid">
  61. <?php
  62. $productImage = $block->getImage($_product, $image);
  63. if ($pos != null) {
  64. $position = ' style="left:' . $productImage->getWidth() . 'px;' . 'top:' . $productImage->getHeight() . 'px;"';
  65. }
  66.  
  67. $_productNameStripped = $block->stripTags($_product->getName(), null, true);
  68. ?>
  69.  
  70. <?php // Product Title ?>
  71. <strong class="product name product-item-name">
  72. <a class="product-item-link" href="<?php echo $_product->getProductUrl() ?>">
  73. <?php /* @escapeNotVerified */ echo strtoupper($_helper->productAttribute($_product, $_product->getName(), 'name')); ?>
  74. </a>
  75. </strong>
  76.  
  77. <?php
  78. // loading the non cached image url
  79. $storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface');
  80. $currentStore = $storeManager->getStore();
  81. $baseMediaUrl = $currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
  82. $thumbUrl = $baseMediaUrl . 'catalog/product' . $_product->getImage();
  83.  
  84. // check if image thumbnail exists
  85. $fileExists = (@fopen($thumbUrl, "r")) ? true : false;
  86.  
  87. // if thumbnail not exists, we loadd the placeholder image
  88. if (!$fileExists) {
  89. $imageHelper = $objectManager->get('Magento\Catalog\Helper\Image');
  90. $thumbUrl = $imageHelper->getDefaultPlaceholderUrl('image');
  91. }
  92. ?>
  93.  
  94. <?php // Product Image ?>
  95. <div class="sq-image">
  96. <a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">
  97. <?php /* @escapeNotVerified */ //echo $productImage->toHtml(); ?>
  98. <span class="product-image-container" style="width:240px;">
  99. <span class="product-image-wrapper" style="padding-bottom:125%;">
  100. <img class="product-image-photo" src="<?php echo $thumbUrl; ?>" alt="<?php echo $_product->getName(); ?>">
  101. </span>
  102. </span>
  103. </a>
  104.  
  105. <?php
  106. // check for cf_1, cf_2, cf_3 custom attributes and if they existing show them in list item.
  107. $uspString = '<ul class="usp-ul">';
  108.  
  109. if (!is_null($_product->getData('cf_1')) || $_product->getData('cf_1') != "") {
  110. $explode1 = explode(":", $_product->getData('cf_1'));
  111. $uspString .= '<li class="usp-li-class">' . $explode1[0] . "<strong>" . (count($explode1) > 1 ? ":" . $explode1[1] : '') . "</strong></li>";
  112. }
  113.  
  114. if (!is_null($_product->getData('cf_2')) || $_product->getData('cf_2') != "") {
  115. $explode2 = explode(":", $_product->getData('cf_2'));
  116. $uspString .= '<li class="usp-li-class">' . $explode2[0] . "<strong>" . (count($explode2) > 1 ? ":" . $explode2[1] : '') . "</strong></li>";
  117. }
  118.  
  119. if (!is_null($_product->getData('cf_3')) || $_product->getData('cf_3') != "") {
  120. $explode3 = explode(":", $_product->getData('cf_3'));
  121. $uspString .= '<li class="usp-li-class">' . $explode3[0] . "<strong>" . (count($explode3) > 1 ? ":" . $explode3[1] : '') . "</strong></li>";
  122. }
  123.  
  124. $uspString .= "</ul>";
  125.  
  126. $reviewSummary = $block->getReviewsSummaryHtml($_product, $templateType);
  127. ?>
  128.  
  129. <?php processNone($qty, $_product); ?>
  130.  
  131. </div>
  132.  
  133. <?php $discounted = false; ?>
  134. <?php if ($_product->getSpecialPrice() != null): ?>
  135. <?php $discounted = true; ?>
  136. <div class="discount-price-tag">aanbieding!</div>
  137. <?php endif; ?>
  138.  
  139. <div class="main-cont">
  140.  
  141. <?php if ($reviewSummary != ""): ?>
  142. <div class="ratings-container">
  143. <?= $reviewSummary ?>
  144. </div>
  145. <?php endif; ?>
  146.  
  147. <!-- showing the unique selling points -->
  148. <?php echo $uspString; ?>
  149.  
  150. <a href="<?php echo $_product->getProductUrl() ?>">
  151. <div class="price-cart-main-container-list">
  152. <div class="price-container-list">
  153. <?php if ($_product->getIsSalable() || !$_product->getIsSalable()): ?>
  154. <!-- PRICE -->
  155. <div class="home_price_cart_group_fixed_height" <?php echo $mode == 'info' ? 'style="display:none;"' : ''; ?> >
  156. <div class="home_price_group">
  157. <div class="home_price"><?php /* @escapeNotVerified */ echo $block->getProductPrice($_product); ?></div>
  158. </div>
  159. </div>
  160. <!-- PRICE END -->
  161. <?php endif; ?>
  162. <!-- STOCK -->
  163. <div <?php echo $mode == 'info' ? 'style="display:none!important;"' : ''; ?> class="actions-primary"<?php echo strpos($pos, $viewMode . '-primary') ? $position : ''; ?>>
  164. <!-- IN STOCK -->
  165. <?php if ($_product->getIsSalable()): ?>
  166. <?php $_product->getData('expected_date') == null ? $expectedDate = "" : $expectedDate = $_product->getData('expected_date'); ?>
  167. <?php if (!$_product->getIsSalable() && $expectedDate != ""): ?>
  168. <p><font style="color: red; font-weight: bold">Niet Voorradig</font> Verwacht: <?php echo $expectedDate ?></p>
  169. <?php else: ?>
  170. <div class="home_in_stock"><?php /* @escapeNotVerified */ echo ($_product->getIsSalable() && $qty > 0) ? __("Morgen in huis") : __('In stock') ?></div>
  171. <?php endif; ?>
  172. <?php else: ?>
  173. <?php if ($_product->getData('expected_date') == null): ?>
  174. <div class="home_out_stock"><?php /* @escapeNotVerified */ echo __('Out of stock') ?></div>
  175. <?php else: ?>
  176. <?php //showing expected date message ?>
  177. <?php $_product->getData('expected_date') == null ? $expectedDate = "" : $expectedDate = $_product->getData('expected_date'); ?>
  178. <?php if ($expectedDate != ""): ?>
  179. <p><font style="color: red; font-weight: bold">Niet Voorradig</font> Verwacht: <?php echo $expectedDate ?></p>
  180. <?php endif; ?>
  181. <?php endif; ?>
  182. <?php endif; ?>
  183. <!-------------->
  184. </div>
  185. <!-- STOCK END -->
  186. </div>
  187. <div class="cart-container-list">
  188. <!-- ADD TO CART BUTTON -->
  189. <?php if ($_product->getIsSalable()): ?>
  190. <?php $postParams = $block->getAddToCartPostParams($_product); ?>
  191. <form data-role="tocart-form" action="<?php /* @escapeNotVerified */ echo $postParams['action']; ?>" method="post">
  192. <input type="hidden" name="product" value="<?php /* @escapeNotVerified */ echo $postParams['data']['product']; ?>">
  193. <input type="hidden" name="<?php /* @escapeNotVerified */ echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php /* @escapeNotVerified */ echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
  194. <?php /* @escapeNotVerified */ echo $block->getBlockHtml('formkey') ?>
  195.  
  196. <?php if ($mode == "info"): ?>
  197. <button type="submit"
  198. style="display:none;"
  199. title="<?php /* @escapeNotVerified */ echo $block->escapeHtml(__('Add to cart')); ?>"
  200. class="action primary tocart home_cart_button">
  201. </button>
  202. <?php else: ?>
  203. <button type="submit"
  204. title="<?php /* @escapeNotVerified */ echo $block->escapeHtml(__('Add to cart')); ?>"
  205. class="action primary tocart home_cart_button">
  206. </button>
  207. <?php endif; ?>
  208. </form>
  209.  
  210. <?php //showing the add to cart button even if out of stock but expected date is defined ?>
  211. <?php elseif (!$_product->isSaleable() && $_product->getData('expected_date') != null): ?>
  212. <button type="submit"
  213. title="<?php /* @escapeNotVerified */ echo $block->escapeHtml(__('Add to cart')); ?>"
  214. class="action primary tocart home_cart_button">
  215. </button>
  216. <?php endif; ?>
  217. <!-- ADD TO CART BUTTON ENDS -->
  218. </div>
  219. </div>
  220. </a>
  221. </div>
  222. </div>
  223. <?php echo($iterator == count($_productCollection) + 1) ? '</li>' : '' ?>
  224. <?php endforeach; ?>
  225. </ol>
  226. </div>
  227. <?php echo $block->getToolbarHtml() ?>
  228. <?php if (!$block->isRedirectToCartEnabled()) : ?>
  229. <div class="toolbar-bottom">
  230. <div class="toolbar bottom">
  231. <?php echo $block->getPagerHtml(); ?>
  232. </div>
  233. </div>
  234. <script type="text/x-magento-init">
  235. {
  236. "[data-role=tocart-form], .form.map.checkout": {
  237. "catalogAddToCart": {}
  238. }
  239. }
  240. </script>
  241. <?php endif; ?>
  242. <?php endif; ?>
  243.  
  244. <?php
  245.  
  246. function processNone($qty, $_product) {
  247. if ($qty > 0) {
  248. if ($_product->isSaleable()) {
  249. // stock is ok and sessable
  250. if (!is_null($_product->getData('delivery_48')) && $_product->getData('delivery_48') == "1" && $qty <= 0) {
  251. 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;">';
  252. echo '<span>Binnen 48 uur verzonden</span>';
  253. echo '</div>';
  254. return;
  255. } else {
  256. 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;">';
  257. echo '<span>Binnen 24 uur verzonden</span>';
  258. echo '</div>';
  259. return;
  260. }
  261. } else {
  262. // stock is ok but not sellable
  263. if (!is_null($_product->getData('expected_date'))) {
  264. $expectedDate = $_product->getData('expected_date');
  265. echo '<p><font style = "color: red; font-weight: bold">Niet Voorradig</font> Verwacht: ' . $expectedDate . '</p>';
  266. echo 'Dit product is tijdelijk niet leverbaar. U kunt hem wel bestellen maar de verwachte leverdatum is: ' . $expectedDate;
  267. return;
  268. } else {
  269. echo '<style type="text/css">.price-and-ratings{display: none!important;} .product-price-box{background-color: white; border: none;}</style>';
  270. echo '<span> <p class="product-ask-info-red">' . __('Tijdelijk niet leverbaar vraag voor meer informatie') . '</p></span>';
  271. return;
  272. }
  273. }
  274. } else {
  275. if ($_product->isSaleable()) {
  276. //stock is not ok but sellable
  277. if (!is_null($_product->getData('delivery_48')) && $_product->getData('delivery_48') == "1") {
  278. 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;">';
  279. echo '<span>Binnen 48 uur verzonden</span>';
  280. echo '</div>';
  281. return;
  282. }
  283. }
  284. }
  285. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement