Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
- $store = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore();
- $_helper = $this->helper('Kemana\Homepage\Helper\Data');
- $priceHelper = $objectManager->create('Magento\Framework\Pricing\Helper\Data');
- $_cat1Enable = $_helper->getConfig('homepage/general/cat1_enable');
- $_cat2Enable = $_helper->getConfig('homepage/general/cat2_enable');
- $_cat3Enable = $_helper->getConfig('homepage/general/cat3_enable');
- $_cat1Title = $_helper->getConfig('homepage/general/cat1_title');
- $_cat2Title = $_helper->getConfig('homepage/general/cat2_title');
- $_cat3Title = $_helper->getConfig('homepage/general/cat3_title');
- $_cat1Select = $_helper->getConfig('homepage/general/cat1_select');
- $_cat2Select = $_helper->getConfig('homepage/general/cat2_select');
- $_cat3Select = $_helper->getConfig('homepage/general/cat3_select');
- $_productLimit = $_helper->getConfig('homepage/general/trending_limit');
- // $categoryId = $_helper->getConfig('homepage/general/category');
- /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */
- $productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection');
- $_cat1 = $objectManager
- ->create('Magento\Catalog\Model\Category')->load($_cat1Select);
- $_cat2 = $objectManager
- ->create('Magento\Catalog\Model\Category')->load($_cat2Select);
- $_cat3 = $objectManager
- ->create('Magento\Catalog\Model\Category')->load($_cat3Select);
- // $_TrendingConfig = $this->getLayout()->createBlock('Kemana\Homepage\Block\HomeTrendingProduct');
- $_trendingConfig = $block->getTrendingConfig();
- $_trendingLimit = $_trendingConfig->getTrendingLimit();
- ?>
- <div class="trending-product__header">
- <h2 class="trending-header__title"> <?php echo $_trendingConfig->getTrendingTitle(); ?></h1>
- <div class="trending-header__category">
- <div class="trending-category__tab" id="catTabs">
- <ul class="nav nav-tabs">
- <?php if($_trendingConfig->getCat1Status() == 1): ?>
- <li class="active"><a href="#trend1" data-toggle="tab"><?php echo $_trendingConfig->getCat1Title(); ?></a></li>
- <?php endif; ?>
- <?php if($_trendingConfig->getCat2Status() == 1): ?>
- <li><a href="#trend2" data-toggle="tab"><?php echo $_trendingConfig->getCat2Title(); ?></a></li>
- <?php endif; ?>
- <?php if($_trendingConfig->getCat3Status() == 1): ?>
- <li><a href="#trend3" data-toggle="tab"><?php echo $_trendingConfig->getCat3Title(); ?></a></li>
- <?php endif; ?>
- </ul>
- <div class="tab-content ">
- <?php if($_trendingConfig->getCat1Status() == 1):?>
- <div class="tab-pane active" id="trend1">
- <div class="trending-product__content owl-carousel owl-theme <?php echo $_trendingConfig->getCat1Value()?>" id="cat1">
- <?php
- $_cat1Id = $_trendingConfig->getCat1Value();
- $_product1 = $block->getProductCollection($_cat1Id, $_trendingLimit);
- foreach ($_product1 as $product1):
- $imageUrl = $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product1->getImage();
- $productTypeInstance = $objectManager->get('Magento\ConfigurableProduct\Model\Product\Type\Configurable');
- $productAttributeOptions = $productTypeInstance->getConfigurableAttributesAsArray($product1);
- $productAttribute = $block->getConfigurableProduct($product1);
- ?>
- <div class="trending-item item">
- <a href="<?php echo $product1->getProductUrl();?>" class="trending-item__images">
- <img src="<?php echo $imageUrl;?>" alt="<?php echo $product1->getName()?>"/>
- </a>
- <div class="trending-item__content">
- <div class="trending-content__summary">
- <span class="trending-summary__color">
- <?php foreach ($productAttribute as $key => $value) {
- $tmp_option = $value['values'];
- $_value = strtolower($value['label']);
- if($_value == 'color'):
- echo count($tmp_option) . ' Colours';
- endif;
- } ?>
- </span>
- <span class="trending-summary__label">
- <?php if($product1->getNew() != 0){
- echo 'NEW';
- } ?>
- </span>
- </div>
- <a href="<?php echo $product1->getProductUrl();?>" class="trending-content__title">
- <span class="trending-title"><?php echo $product1->getName()?></span>
- </a>
- <a href="<?php echo $product1->getProductUrl();?>" class="trending-content__category">
- <span class="trending-category"> <?php echo $_cat1->getName();?></span>
- </a>
- <div class="trending-content__prices">
- <?php if($product1->getSale() == 0){?>
- <span class="regular-prices"> <?php echo $priceHelper->currency($product1->getFinalPrice(), true, false);?></span>
- <?php }else { ?>
- <div class="sales-prices">
- <span class="price"> MYR 140.00</span>
- <span class="price-text"> (30% off) </span>
- </div>
- <?php } ?>
- </div>
- </div>
- </div>
- <?php endforeach; ?>
- </div>
- </div>
- <?php endif; ?>
- <?php if($_trendingConfig->getCat2Status() == 1):?>
- <div class="tab-pane" id="trend2">
- <div class="trending-product__content owl-carousel owl-theme <?php echo $_trendingConfig->getCat2Value()?>" id="cat2">
- <?php
- $_cat2Id = $_trendingConfig->getCat1Value();
- $_product2 = $block->getProductCollection($_cat2Id, $_trendingLimit);
- foreach ($_product2 as $product2):
- $imageUrl2 = $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product2->getImage();
- $product2TypeInstance = $objectManager->get('Magento\ConfigurableProduct\Model\Product\Type\Configurable');
- $product2AttributeOptions = $product2TypeInstance->getConfigurableAttributesAsArray($product2);
- ?>
- <div class="trending-item item">
- <a href="<?php echo $product2->getProductUrl();?>" class="trending-item__images">
- <img src="<?php echo $imageUrl2;?>" alt="<?php echo $product2->getName()?>"/>
- </a>
- <div class="trending-item__content">
- <div class="trending-content__summary">
- <span class="trending-summary__color">
- <?php foreach ($product2AttributeOptions as $key => $value) {
- $tmp_option = $value['values'];
- $_value = strtolower($value['label']);
- if($_value == 'color'):
- echo count($tmp_option) . ' Colours';
- endif;
- } ?>
- </span>
- <span class="trending-summary__label">
- <?php if($product2->getNew() != 0){
- echo 'NEW';
- } ?>
- </span>
- </div>
- <a href="<?php echo $product2->getProductUrl();?>" class="trending-content__title">
- <span class="trending-title"><?php echo $product2->getName()?></span>
- </a>
- <a href="<?php echo $product2->getProductUrl();?>" class="trending-content__category">
- <span class="trending-category"> <?php echo $_cat2->getName();?></span>
- </a>
- <div class="trending-content__prices">
- <?php if($product2->getSale() == 0){?>
- <span class="regular-prices"> <?php echo $priceHelper->currency($product2->getFinalPrice(), true, false);?></span>
- <?php }else { ?>
- <div class="sales-prices">
- <span class="price"> MYR 140.00</span>
- <span class="price-text"> (30% off) </span>
- </div>
- <?php } ?>
- </div>
- </div>
- </div>
- <?php endforeach; ?>
- </div>
- </div>
- <?php endif; ?>
- <?php if($_cat3Enable == 1):?>
- <div class="tab-pane" id="trend3">
- <div class="trending-product__content owl-carousel owl-theme" id="cat3">
- <?php
- $_product3 = $productCollection->addAttributeToFilter('type_id', 'configurable')
- ->addAttributeToSelect('*')
- ->addCategoriesFilter(['eq' => $_cat3Select])
- ->setPageSize($_productLimit)
- ->setCurPage(1)->load();
- foreach ($_product3 as $product):
- $imageUrl = $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();
- $productTypeInstance = $objectManager->get('Magento\ConfigurableProduct\Model\Product\Type\Configurable');
- $productAttributeOptions = $productTypeInstance->getConfigurableAttributesAsArray($product);
- ?>
- <div class="trending-item item">
- <a href="<?php echo $product->getProductUrl();?>" class="trending-item__images">
- <img src="<?php echo $imageUrl;?>" alt="<?php echo $product->getName()?>"/>
- </a>
- <div class="trending-item__content">
- <div class="trending-content__summary">
- <span class="trending-summary__color">
- <?php foreach ($productAttributeOptions as $key => $value) {
- $tmp_option = $value['values'];
- $_value = strtolower($value['label']);
- if($_value == 'color'):
- echo count($tmp_option) . ' Colours';
- endif;
- } ?>
- </span>
- <span class="trending-summary__label">
- <?php if($product->getNew() != 0){
- echo 'NEW';
- } ?>
- </span>
- </div>
- <a href="<?php echo $product->getProductUrl();?>" class="trending-content__title">
- <span class="trending-title"><?php echo $product->getName()?></span>
- </a>
- <a href="<?php echo $product->getProductUrl();?>" class="trending-content__category">
- <span class="trending-category"> <?php echo $_cat3->getName();?></span>
- </a>
- <div class="trending-content__prices">
- <?php if($product->getSale() == 0){?>
- <span class="regular-prices"> <?php echo $priceHelper->currency($product->getFinalPrice(), true, false);?></span>
- <?php }else { ?>
- <div class="sales-prices">
- <span class="price"> MYR 140.00</span>
- <span class="price-text"> (30% off) </span>
- </div>
- <?php } ?>
- </div>
- </div>
- </div>
- <?php endforeach; ?>
- </div>
- </div>
- <?php endif; ?>
- </div>
- </div>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement