|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / a / home / dev2.destoffenstraat.com / app / code / SR / Inspiration / Block / |
Filename | /home/a/home/dev2.destoffenstraat.com/app/code/SR/Inspiration/Block/Themeslider.php |
Size | 3.46 kb |
Permission | rwxrwxrwx |
Owner | root : root |
Create time | 21-Aug-2025 12:26 |
Last modified | 06-Apr-2021 18:06 |
Last accessed | 22-Aug-2025 17:22 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
namespace SR\Inspiration\Block;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
use Magento\Catalog\Model\CategoryFactory;
use Magento\Framework\Pricing\Helper\Data as priceHelper;
class Themeslider extends \Magento\Framework\View\Element\Template
{
protected $customCollection;
protected $priceHepler;
public function __construct(Context $context,
CollectionFactory $customCollection,
priceHelper $priceHepler,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\Registry $registry,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
CategoryFactory $categoryFactory
)
{
$this->customCollection = $customCollection;
$this->priceHepler = $priceHepler;
$this->_storeManager = $storeManager;
$this->_registry = $registry;
$this->scopeConfig = $scopeConfig;
$this->_categoryFactory = $categoryFactory;
parent::__construct($context);
}
public function getCustomCollection()
{
$collection = $this->customCollection->create()->addAttributeToSelect('*')->setStore($this->_storeManager->getStore());
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
$catid = 357;//$this->scopeConfig->getValue("theme_settings/category/parent_category_theme_slider", $storeScope);
$current = $this->_registry->registry("current_category");
if($current && $current->getId())
{
$parentcategoryId = $current->getParentCategory()->getParentCategory()->getId();
if($parentcategoryId){
$parentparentcategory = $this->_categoryFactory->create()->load($parentcategoryId);
if($parentparentcategory && $parentparentcategory->getId()==$catid){
$category = $this->_categoryFactory->create()->load($catid);
if($category && $category->getId()){
$collection->addFieldToFilter("path",array('like'=>$category->getPath().'/%'));
$collection->addFieldToFilter('is_active',1);
$collection->addFieldToFilter('level',4);
$collection->setOrder('position','asc');
$collection->setPageSize(9);
$collection->setCurPage(1);
return $collection;
}
}
}
}
if ($this->getRequest()->getFullActionName() == 'cms_index_index') {
$category = $this->_categoryFactory->create()->load($catid);
if($category && $category->getId()){
$collection->addFieldToFilter("path",array('like'=>$category->getPath().'/%'));
$collection->addFieldToFilter('is_active',1);
$collection->addFieldToFilter('level',4);
$collection->setOrder('position','asc');
$collection->setPageSize(9);
$collection->setCurPage(1);
return $collection;
}
}
}
public function isHomepage() {
if ($this->getRequest()->getFullActionName() == 'cms_index_index') {
return true;
}
return false;
}
}
namespace SR\Inspiration\Block;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
use Magento\Catalog\Model\CategoryFactory;
use Magento\Framework\Pricing\Helper\Data as priceHelper;
class Themeslider extends \Magento\Framework\View\Element\Template
{
protected $customCollection;
protected $priceHepler;
public function __construct(Context $context,
CollectionFactory $customCollection,
priceHelper $priceHepler,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\Registry $registry,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
CategoryFactory $categoryFactory
)
{
$this->customCollection = $customCollection;
$this->priceHepler = $priceHepler;
$this->_storeManager = $storeManager;
$this->_registry = $registry;
$this->scopeConfig = $scopeConfig;
$this->_categoryFactory = $categoryFactory;
parent::__construct($context);
}
public function getCustomCollection()
{
$collection = $this->customCollection->create()->addAttributeToSelect('*')->setStore($this->_storeManager->getStore());
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
$catid = 357;//$this->scopeConfig->getValue("theme_settings/category/parent_category_theme_slider", $storeScope);
$current = $this->_registry->registry("current_category");
if($current && $current->getId())
{
$parentcategoryId = $current->getParentCategory()->getParentCategory()->getId();
if($parentcategoryId){
$parentparentcategory = $this->_categoryFactory->create()->load($parentcategoryId);
if($parentparentcategory && $parentparentcategory->getId()==$catid){
$category = $this->_categoryFactory->create()->load($catid);
if($category && $category->getId()){
$collection->addFieldToFilter("path",array('like'=>$category->getPath().'/%'));
$collection->addFieldToFilter('is_active',1);
$collection->addFieldToFilter('level',4);
$collection->setOrder('position','asc');
$collection->setPageSize(9);
$collection->setCurPage(1);
return $collection;
}
}
}
}
if ($this->getRequest()->getFullActionName() == 'cms_index_index') {
$category = $this->_categoryFactory->create()->load($catid);
if($category && $category->getId()){
$collection->addFieldToFilter("path",array('like'=>$category->getPath().'/%'));
$collection->addFieldToFilter('is_active',1);
$collection->addFieldToFilter('level',4);
$collection->setOrder('position','asc');
$collection->setPageSize(9);
$collection->setCurPage(1);
return $collection;
}
}
}
public function isHomepage() {
if ($this->getRequest()->getFullActionName() == 'cms_index_index') {
return true;
}
return false;
}
}