Exemple #1
0
 protected function _prepareCollection()
 {
     $storeViewId = $this->getRequest()->getParam('store');
     /** @var \Magestore\Bannerslider\Model\ResourceModel\Banner\Collection $collection */
     $collection = $this->_bannerCollectionFactory->create()->setStoreViewId($storeViewId);
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
 public function getSelectedSliderBanners()
 {
     $sliderId = $this->getRequest()->getParam('slider_id');
     if (!isset($sliderId)) {
         return [];
     }
     $bannerCollection = $this->_bannerCollectionFactory->create();
     $bannerCollection->addFieldToFilter('slider_id', $sliderId);
     $bannerIds = [];
     foreach ($bannerCollection as $banner) {
         $bannerIds[$banner->getId()] = ['order_banner_slider' => $banner->getOrderBanner()];
     }
     return $bannerIds;
 }
 /**
  * get banner collection of slider.
  *
  * @return \Magestore\Bannerslider\Model\ResourceModel\Banner\Collection
  */
 public function getBannerCollection()
 {
     $storeViewId = $this->_storeManager->getStore()->getId();
     $dateTimeNow = $this->_stdTimezone->date()->format('Y-m-d H:i:s');
     /** @var \Magestore\Bannerslider\Model\ResourceModel\Banner\Collection $bannerCollection */
     $bannerCollection = $this->_bannerCollectionFactory->create()->setStoreViewId($storeViewId)->addFieldToFilter('slider_id', $this->_slider->getId())->addFieldToFilter('status', Status::STATUS_ENABLED)->addFieldToFilter('start_time', ['lteq' => $dateTimeNow])->addFieldToFilter('end_time', ['gteq' => $dateTimeNow])->setOrder('order_banner', 'ASC');
     if ($this->_slider->getSortType() == SliderModel::SORT_TYPE_RANDOM) {
         $bannerCollection->setOrderRandByBannerId();
     }
     return $bannerCollection;
 }
 /**
  * get banner collection of slider.
  *
  * @return \Magestore\Bannerslider\Model\ResourceModel\Banner\Collection
  */
 public function getOwnBanerCollection()
 {
     return $this->_bannerCollectionFactory->create()->addFieldToFilter('slider_id', $this->getId());
 }