Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssociatedProductsCollection.php
Go to the documentation of this file.
1 <?php
9 
13 class AssociatedProductsCollection extends \Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection
14 {
20  protected $_coreRegistry = null;
21 
27  protected $_config;
28 
57  public function __construct(
58  \Magento\Framework\Data\Collection\EntityFactory $entityFactory,
59  \Psr\Log\LoggerInterface $logger,
60  \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
61  \Magento\Framework\Event\ManagerInterface $eventManager,
62  \Magento\Eav\Model\Config $eavConfig,
63  \Magento\Framework\App\ResourceConnection $resource,
64  \Magento\Eav\Model\EntityFactory $eavEntityFactory,
65  \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper,
66  \Magento\Framework\Validator\UniversalFactory $universalFactory,
67  \Magento\Store\Model\StoreManagerInterface $storeManager,
68  \Magento\Framework\Module\Manager $moduleManager,
69  \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState,
70  \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
71  \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory,
72  \Magento\Catalog\Model\ResourceModel\Url $catalogUrl,
73  \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
74  \Magento\Customer\Model\Session $customerSession,
75  \Magento\Framework\Stdlib\DateTime $dateTime,
76  \Magento\Customer\Api\GroupManagementInterface $groupManagement,
77  \Magento\Framework\Registry $coreRegistry,
78  \Magento\Catalog\Model\ProductTypes\ConfigInterface $config,
79  \Magento\Framework\DB\Adapter\AdapterInterface $connection = null
80  ) {
81  $this->_coreRegistry = $coreRegistry;
82  $this->_config = $config;
83  parent::__construct(
84  $entityFactory,
85  $logger,
86  $fetchStrategy,
87  $eventManager,
88  $eavConfig,
89  $resource,
90  $eavEntityFactory,
91  $resourceHelper,
92  $universalFactory,
95  $catalogProductFlatState,
96  $scopeConfig,
97  $productOptionFactory,
98  $catalogUrl,
99  $localeDate,
100  $customerSession,
101  $dateTime,
102  $groupManagement,
104  );
105  }
106 
112  protected function _getProduct()
113  {
114  return $this->_coreRegistry->registry('current_product');
115  }
116 
120  public function _initSelect()
121  {
122  parent::_initSelect();
123  $this->setProduct(
124  $this->_getProduct()
125  )->addAttributeToSelect(
126  'name'
127  )->addAttributeToSelect(
128  'price'
129  )->addAttributeToSelect(
130  'sku'
131  )->addFilterByRequiredOptions()->addAttributeToFilter(
132  'type_id',
133  $this->_config->getComposableTypes()
134  );
135 
136  return $this;
137  }
138 }
$config
Definition: fraud_order.php:17
__construct(\Magento\Framework\Data\Collection\EntityFactory $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\App\ResourceConnection $resource, \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\ResourceModel\Url $catalogUrl, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Customer\Api\GroupManagementInterface $groupManagement, \Magento\Framework\Registry $coreRegistry, \Magento\Catalog\Model\ProductTypes\ConfigInterface $config, \Magento\Framework\DB\Adapter\AdapterInterface $connection=null)
$storeManager
$resource
Definition: bulk.php:12
$logger
$connection
Definition: bulk.php:13