Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. PlazathemesBrandsliderModelResourceModelBrandCollection
  2. Incompatible argument type: Required type: MagentoFrameworkDBAdapterAdapterInterface. Actual type: MagentoFrameworkModelResourceModelDbAbstractDb;
  3. File:/home/rbadmin/public_html/app/code/Plazathemes/Brandslider/Model/ResourceModel/Brand/Collection.php
  4. Total Errors Count: 1
  5. [MagentoFrameworkValidatorException]
  6. Error during compilation
  7.  
  8. <?php
  9. /**
  10. * Copyright © 2015 PlazaThemes.com. All rights reserved.
  11.  
  12. * @author PlazaThemes Team <contact@plazathemes.com>
  13. */
  14.  
  15. namespace PlazathemesBrandsliderModelResourceModelBrand;
  16.  
  17. class Collection extends
  18. MagentoFrameworkModelResourceModelDbCollectionAbstractCollection {
  19. /**
  20. * store view id
  21. * @var int
  22. */
  23. protected $_storeViewId = null;
  24.  
  25. /**
  26. * @var MagentoStoreModelStoreManagerInterface
  27. */
  28. protected $_storeManager;
  29.  
  30. protected $_addedTable = [];
  31.  
  32. protected function _construct() {
  33. $this->_init('PlazathemesBrandsliderModelBrand', 'PlazathemesBrandsliderModelResourceModelBrand');
  34. }
  35.  
  36. /**
  37. * @param MagentoFrameworkDataCollectionEntityFactoryInterface $entityFactory
  38. * @param PsrLogLoggerInterface $logger
  39. * @param MagentoFrameworkDataCollectionDbFetchStrategyInterface $fetchStrategy
  40. * @param MagentoFrameworkEventManagerInterface $eventManager
  41. * @param Zend_Db_Adapter_Abstract $connection
  42. * @param MagentoFrameworkModelResourceModelDbAbstractDb $resource
  43. */
  44. public function __construct(
  45. MagentoFrameworkDataCollectionEntityFactoryInterface $entityFactory,
  46. PsrLogLoggerInterface $logger,
  47. MagentoFrameworkDataCollectionDbFetchStrategyInterface $fetchStrategy,
  48. MagentoFrameworkEventManagerInterface $eventManager,
  49. MagentoStoreModelStoreManagerInterface $storeManager,
  50. $connection = null,
  51. MagentoFrameworkModelResourceModelDbAbstractDb $resource = null
  52. ) {
  53. parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection);
  54. $this->_storeManager = $storeManager;
  55.  
  56. if ($storeViewId = $this->_storeManager->getStore()->getId()) {
  57. $this->_storeViewId = $storeViewId;
  58. }
  59. }
  60.  
  61. /**
  62. * get store view id
  63. * @return int [description]
  64. */
  65. public function getStoreViewId() {
  66. return $this->_storeViewId;
  67. }
  68.  
  69. /**
  70. * set store view id
  71. * @param int $storeViewId [description]
  72. */
  73. public function setStoreViewId($storeViewId) {
  74. $this->_storeViewId = $storeViewId;
  75. return $this;
  76. }
  77.  
  78. /**
  79. * Multi store view
  80. * @param string|array $field
  81. * @param null|string|array $condition
  82. */
  83. public function addFieldToFilter($field, $condition = null) {
  84. $attributes = array(
  85. 'name',
  86. 'status',
  87. 'click_url',
  88. 'image_alt',
  89. 'store_id',
  90. );
  91. $storeViewId = $this->getStoreViewId();
  92. if (in_array($field, $attributes) && $storeViewId) {
  93. if (!in_array($field, $this->_addedTable)) {
  94. $this->getSelect();
  95. $this->_addedTable[] = $field;
  96. }
  97. // return parent::addFieldToFilter("IF($field.value IS NULL, main_table.$field, $field.value)", $condition);
  98. return parent::addFieldToFilter($field, $condition);
  99. }
  100. if ($field == 'store_id') {
  101. $field = 'main_table.brand_id';
  102. }
  103. return parent::addFieldToFilter($field, $condition);
  104. }
  105.  
  106. /**
  107. * Multi store view
  108. */
  109. protected function _afterLoad() {
  110. parent::_afterLoad();
  111. if ($storeViewId = $this->getStoreViewId()) {
  112. foreach ($this->_items as $item) {
  113. $item->setStoreViewId($storeViewId)->getStoreViewValue();
  114. }
  115. }
  116. return $this;
  117. }
  118.  
  119. /**
  120. * set order random by brand id
  121. *
  122. * @return $this
  123. */
  124. public function setOrderByBrand()
  125. {
  126. $this->getSelect()->order('order');
  127.  
  128. return $this;
  129. }
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement