Example #1
0
 /**
  * Initialize source entities and collections
  *
  * @param array $data
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _initSourceEntities(array $data)
 {
     if (isset($data['data_source_model'])) {
         $this->_dataSourceModel = $data['data_source_model'];
     }
     if (isset($data['product_model'])) {
         $this->_productModel = $data['product_model'];
     } else {
         $this->_productModel = $this->_productFactory->create();
     }
     if (isset($data['option_collection'])) {
         $this->_optionCollection = $data['option_collection'];
     } else {
         $this->_optionCollection = $this->_optionColFactory->create();
     }
     if (isset($data['product_entity'])) {
         $this->_productEntity = $data['product_entity'];
     } else {
         throw new \Magento\Framework\Exception\LocalizedException(__('Every option entity must have a parent product entity.'));
     }
     if (isset($data['collection_by_pages_iterator'])) {
         $this->_byPagesIterator = $data['collection_by_pages_iterator'];
     } else {
         $this->_byPagesIterator = $this->_colIteratorFactory->create();
     }
     if (isset($data['page_size'])) {
         $this->_pageSize = $data['page_size'];
     } else {
         $this->_pageSize = self::XML_PATH_PAGE_SIZE ? (int) $this->_scopeConfig->getValue(self::XML_PATH_PAGE_SIZE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE) : 0;
     }
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 public function getProductOptions(ProductInterface $product, $requiredOnly = false)
 {
     return $this->collectionFactory->create()->getProductOptions($product->getEntityId(), $product->getStoreId(), $requiredOnly);
 }