srapsware

Untitled

Oct 21st, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.27 KB | None | 0 0
  1. <?php
  2. $blockId = rand() . time();
  3. $products = $this->getProductCollection();
  4. $themeHelper = $this->helper('MGS\Mpanel\Helper\Data');
  5. $themeSettings = $themeHelper->getThemeSettings();
  6. $type = 'widget-product-grid';
  7. $image = 'category_page_grid';
  8. $imageTwo = 'category_page_two_list';
  9. ?>
  10. <?php $quickViewHelper = $this->helper('MGS\QuickView\Helper\Data'); ?>
  11. <?php if($this->getData('per_row_grid') != null){
  12.     $perRow = $this->getData('per_row_grid');
  13. }else {
  14.     $perRow = $themeSettings['catalog']['per_row'];
  15. }
  16.  $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
  17. ?>
  18. <div class="block products-grid <?php if($this->getData('custom_class')): ?><?php echo $this->getData('custom_class')?><?php endif;?>">
  19.     <?php if($this->getData('title')): ?>
  20.         <div class="title-block">
  21.             <h2><?php echo $this->getData('title') ?></h2>
  22.         </div>
  23.     <?php endif ?>
  24.     <?php if(count($products)>0): ?>
  25.         <div class="block-content <?php if($this->getData('slider_mode_grid') != 1): ?>row<?php endif;?>">
  26.             <ol class="products-grid <?php if($this->getData('slider_mode_grid') == 1): ?>owl-carousel<?php endif ?>" id="mgs-grid-product-<?php echo $blockId ?>">
  27.             <?php $i = 0; foreach($products as $_product): $i++;?>
  28.                 <?php   $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
  29.                         $productModel = $objectManager->create('Magento\Catalog\Model\Product');
  30.                         $_product = $productModel->load($_product->getId()); ?>
  31.                 <?php $_itemNameStripped = $block->stripTags($_product->getName(), null, true); ?>
  32.                 <?php $_imagehelper = $this->helper('Magento\Catalog\Helper\Image');
  33.                     $size = $themeHelper->getImageSize();
  34.                     $productImage = $_imagehelper->init($_product, $image)->resize($size['width'], $size['height'])->getUrl();  
  35.                     $_productType = $_product->getTypeID();
  36.                    
  37.                 ?>
  38.                     <?php if($this->getData('slider_mode_grid') == 1): ?>
  39.                         <li class="product-item item">
  40.                     <?php else: ?>
  41.                         <li class="item <?php echo $themeHelper->getColClass($perRow) ?> <?php echo $themeHelper->getClearClass($perRow, $i) ?>">
  42.                     <?php endif ?>
  43.                         <div class="product-item-info product-content">
  44.                             <div class="product-top">
  45.                                 <a href="<?php /* @escapeNotVerified */ echo $block->getProductUrl($_product) ?>" class="product-item-photo">
  46.                                     <img src="<?php echo $productImage; ?>" alt="<?php echo $_itemNameStripped ?>" class="img-responsive"/>                                
  47.                                 </a>
  48.                                 <div class="button-quickview">
  49.                                     <?php echo $quickViewHelper->aroundQuickViewHtml($_product); ?>
  50.                                 </div>
  51.                                 <?php echo $themeHelper->getProductLabel($_product) ?>
  52.                             </div>
  53.                            
  54.                             <div class="product-desc">
  55.                                 <div class="cate-name text-center"><div class="text"><span><?php echo $themeHelper->getCategoryName($_product,$this->getData('title'),'') ?></span></div></div>
  56.                                 <h4 class="product-name product-item-name">
  57.                                     <a class="product-item-link" href="<?php /* @escapeNotVerified */ echo $block->getProductUrl($_product) ?>" title="<?php echo $_itemNameStripped ?>"><?php echo $_product->getName() ?></a>
  58.                                 </h4>
  59.                                 <div class="rating-price">
  60.                                     <?php  echo $block->getProductPrice($_product) ?>
  61.                                     <?php if($templateType): ?>
  62.                                     <?php echo $block->getReviewsSummaryHtml($_product, $templateType, true)?>
  63.                                     <?php endif;?>
  64.                                 </div>
  65.                                 <div class="controls">
  66.                                     <div class="add-to-cart hover-hidden">
  67.                                         <?php if ($_product->isSaleable()): ?>
  68.                                             <?php $url = $this->getAddToCartUrl($_product) ?>
  69.                                             <form data-role="tocart-form" action="<?php echo $url; ?>" method="post">
  70.                                                 <input type="hidden" name="product" value="<?php echo $_product->getId(); ?>">
  71.                                                 <input type="hidden" name="uenc" value="<?php echo $this->getEncodedUrl($url) ?>">
  72.                                                 <?php echo $block->getBlockHtml('formkey')?>
  73.                                                 <button class="tocart btn-icon btn btn-default" type="submit" title="<?php /* @escapeNotVerified */ echo __('Add to Cart') ?>">
  74.                                                     <?php if($_productType =='simple'):?><?php /* @escapeNotVerified */ echo __('Add to Cart') ?><?php else: ?>
  75.                                                     <?php echo __('Select option')?><?php endif;?>
  76.                                                 </button>
  77.                                             </form>
  78.                                         <?php else: ?>
  79.                                             <?php if ($_product->getIsSalable()): ?>
  80.                                                 <div class="stock available"><span><?php /* @escapeNotVerified */ echo __('In stock') ?></span></div>
  81.                                             <?php else: ?>
  82.                                                 <div class="stock unavailable"><span><?php /* @escapeNotVerified */ echo __('Out of stock') ?></span></div>
  83.                                             <?php endif; ?>
  84.                                         <?php endif; ?>
  85.                                     </div>
  86.                                     <div class="controls-hover">
  87.                                         <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()): ?>
  88.                                         <button data-post='<?php /* @escapeNotVerified */ echo $block->getAddToWishlistParams($_product); ?>'
  89.                                            class="action towishlist btn btn-addlist" data-action="add-to-wishlist"
  90.                                            title="<?php /* @escapeNotVerified */ echo __('Add to Wish List') ?>">
  91.                                             <span class="pe-7s-like"></span>
  92.                                         </button>
  93.                                         <?php endif;?>
  94.                                         <?php if ($_product->isSaleable()): ?>
  95.                                             <?php $url = $this->getAddToCartUrl($_product) ?>
  96.                                             <form data-role="tocart-form" action="<?php echo $url; ?>" method="post">
  97.                                                 <input type="hidden" name="product" value="<?php echo $_product->getId(); ?>">
  98.                                                 <input type="hidden" name="uenc" value="<?php echo $this->getEncodedUrl($url) ?>">
  99.                                                 <?php echo $block->getBlockHtml('formkey')?>
  100.                                                 <button class="tocart btn-icon btn btn-addlist" type="submit" title="<?php /* @escapeNotVerified */ echo __('Add to Cart') ?>">
  101.                                                     <span class="icon <?php if($_productType =='simple'):?> pe-7s-shopbag<?php else: ?> pe-7s-menu<?php endif;?>"></span>
  102.                                                 </button>
  103.                                             </form>
  104.                                         <?php endif; ?>
  105.                                        
  106.                                         <?php if ($block->getAddToCompareUrl()): ?>                                
  107.                                         <?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');?>
  108.                                             <button class="action tocompare btn btn-addlist"
  109.                                            data-post='<?php /* @escapeNotVerified */ echo $compareHelper->getPostDataParams($_product);?>'
  110.                                            title="<?php /* @escapeNotVerified */ echo __('Add to Compare') ?>">
  111.                                             <span class="pe-7s-repeat"></span>
  112.                                         </button>
  113.                                         <?php endif;?>
  114.                                     </div>
  115.                                 </div>
  116.                             </div>
  117.                         </div>
  118.                     </li>
  119.             <?php endforeach ?>
  120.             </ol>
  121.         </div>
  122.         <?php if($this->getData('slider_mode_grid') == 1): ?>
  123.             <script type="text/javascript">
  124.                 require([
  125.                     'jquery',
  126.                     'mgs/owlcarousel'
  127.                 ], function ($) {
  128.                     var owl = $('#mgs-grid-product-<?php echo $blockId ?>');
  129.                     owl.owlCarousel({
  130.                         items: <?php echo $perRow ?>,
  131.                         autoPlay: false,
  132.                         stopOnHover: false,
  133.                         margin:30,
  134.                         nav: true,
  135.                         navText: ["<i class='fa fa-angle-left'></i>","<i class='fa fa-angle-right'></i>"],
  136.                         dots: false,
  137.                         responsive:{ 0 : {items: 1}, 480 : {items: 2}, 768 : {items: 2}, 970 : {items: 3}, 1199 : {items: <?php echo $perRow ?>} }
  138.                     });
  139.                 });
  140.             </script>
  141.         <?php endif ?>
  142.     <?php else: ?>
  143.         <div class="alert alert-danger"><?php echo __('No product to show'); ?></div>
  144.     <?php endif ?>
  145. </div>
Add Comment
Please, Sign In to add comment