Files
2017-11-14 15:04:59 +01:00

35 lines
1.1 KiB
PHP

<?php
namespace Edeclic\Parution\Block;
class Parution extends \Magento\Framework\View\Element\Template
{
private $_objectManager;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\ObjectManagerInterface $objectManager,
array $data = []
)
{
parent::__construct($context,$data);
$this->_objectManager = $objectManager;
}
public function getMediaUrl()
{
$mediaUrl = $this ->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA );
return $mediaUrl;
}
public function getCollection()
{
$objectManager = $this->_objectManager->create('Edeclic\Parution\Model\Parution');
$collection = $objectManager->getCollection();
$collection->addFieldToFilter('store_ids',array(array('like'=>'%"'.$this->_storeManager->getStore()->getId().'"%'),array('like'=>'%"0"%')));
$collection->addFieldToFilter('active',1);
$collection->setOrder('date_actu','desc');
return $collection;
}
}