48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Edeclic\News\Block;
|
|
|
|
class News 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 getNews()
|
|
{
|
|
$id = $this->getRequest()->getParams()['id'];
|
|
$objectManager = $this->_objectManager->create('Edeclic\News\Model\News');
|
|
$news = $objectManager->load($id);
|
|
return $news;
|
|
}
|
|
|
|
public function getMediaUrl()
|
|
{
|
|
$mediaUrl = $this ->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA );
|
|
return $mediaUrl;
|
|
}
|
|
|
|
public function getCollection()
|
|
{
|
|
$objectManager = $this->_objectManager->create('Edeclic\News\Model\News');
|
|
$collection = $objectManager->getCollection();
|
|
$collection->addFieldToFilter('store_ids',array(array('like'=>'%"'.$this->_storeManager->getStore()->getId().'"%'),array('like'=>'%"0"%')));
|
|
$collection->addFieldToFilter('active',1);
|
|
return $collection;
|
|
}
|
|
|
|
public function getStoreUrl()
|
|
{
|
|
return $this->_storeManager->getStore()->getBaseUrl();
|
|
}
|
|
|
|
} |