Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PlazathemesBrandsliderModelResourceModelBrandCollection
- Incompatible argument type: Required type: MagentoFrameworkDBAdapterAdapterInterface. Actual type: MagentoFrameworkModelResourceModelDbAbstractDb;
- File:/home/rbadmin/public_html/app/code/Plazathemes/Brandslider/Model/ResourceModel/Brand/Collection.php
- Total Errors Count: 1
- [MagentoFrameworkValidatorException]
- Error during compilation
- <?php
- /**
- * Copyright © 2015 PlazaThemes.com. All rights reserved.
- * @author PlazaThemes Team <contact@plazathemes.com>
- */
- namespace PlazathemesBrandsliderModelResourceModelBrand;
- class Collection extends
- MagentoFrameworkModelResourceModelDbCollectionAbstractCollection {
- /**
- * store view id
- * @var int
- */
- protected $_storeViewId = null;
- /**
- * @var MagentoStoreModelStoreManagerInterface
- */
- protected $_storeManager;
- protected $_addedTable = [];
- protected function _construct() {
- $this->_init('PlazathemesBrandsliderModelBrand', 'PlazathemesBrandsliderModelResourceModelBrand');
- }
- /**
- * @param MagentoFrameworkDataCollectionEntityFactoryInterface $entityFactory
- * @param PsrLogLoggerInterface $logger
- * @param MagentoFrameworkDataCollectionDbFetchStrategyInterface $fetchStrategy
- * @param MagentoFrameworkEventManagerInterface $eventManager
- * @param Zend_Db_Adapter_Abstract $connection
- * @param MagentoFrameworkModelResourceModelDbAbstractDb $resource
- */
- public function __construct(
- MagentoFrameworkDataCollectionEntityFactoryInterface $entityFactory,
- PsrLogLoggerInterface $logger,
- MagentoFrameworkDataCollectionDbFetchStrategyInterface $fetchStrategy,
- MagentoFrameworkEventManagerInterface $eventManager,
- MagentoStoreModelStoreManagerInterface $storeManager,
- $connection = null,
- MagentoFrameworkModelResourceModelDbAbstractDb $resource = null
- ) {
- parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection);
- $this->_storeManager = $storeManager;
- if ($storeViewId = $this->_storeManager->getStore()->getId()) {
- $this->_storeViewId = $storeViewId;
- }
- }
- /**
- * get store view id
- * @return int [description]
- */
- public function getStoreViewId() {
- return $this->_storeViewId;
- }
- /**
- * set store view id
- * @param int $storeViewId [description]
- */
- public function setStoreViewId($storeViewId) {
- $this->_storeViewId = $storeViewId;
- return $this;
- }
- /**
- * Multi store view
- * @param string|array $field
- * @param null|string|array $condition
- */
- public function addFieldToFilter($field, $condition = null) {
- $attributes = array(
- 'name',
- 'status',
- 'click_url',
- 'image_alt',
- 'store_id',
- );
- $storeViewId = $this->getStoreViewId();
- if (in_array($field, $attributes) && $storeViewId) {
- if (!in_array($field, $this->_addedTable)) {
- $this->getSelect();
- $this->_addedTable[] = $field;
- }
- // return parent::addFieldToFilter("IF($field.value IS NULL, main_table.$field, $field.value)", $condition);
- return parent::addFieldToFilter($field, $condition);
- }
- if ($field == 'store_id') {
- $field = 'main_table.brand_id';
- }
- return parent::addFieldToFilter($field, $condition);
- }
- /**
- * Multi store view
- */
- protected function _afterLoad() {
- parent::_afterLoad();
- if ($storeViewId = $this->getStoreViewId()) {
- foreach ($this->_items as $item) {
- $item->setStoreViewId($storeViewId)->getStoreViewValue();
- }
- }
- return $this;
- }
- /**
- * set order random by brand id
- *
- * @return $this
- */
- public function setOrderByBrand()
- {
- $this->getSelect()->order('order');
- return $this;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement