/** * Load exiting custom options data * * @return $this */ protected function _initOldCustomOptions() { if (!$this->_oldCustomOptions) { $oldCustomOptions = array(); $optionTitleTable = $this->_tables['catalog_product_option_title']; $productIds = array_values($this->_productsSkuToId); foreach ($this->_storeCodeToId as $storeId) { $addCustomOptions = function (\Magento\Catalog\Model\Product\Option $customOption) use(&$oldCustomOptions, $storeId) { $productId = $customOption->getProductId(); if (!isset($oldCustomOptions[$productId])) { $oldCustomOptions[$productId] = array(); } if (isset($oldCustomOptions[$productId][$customOption->getId()])) { $oldCustomOptions[$productId][$customOption->getId()]['titles'][$storeId] = $customOption->getTitle(); } else { $oldCustomOptions[$productId][$customOption->getId()] = array('titles' => array($storeId => $customOption->getTitle()), 'type' => $customOption->getType()); } }; /** @var $collection \Magento\Catalog\Model\Resource\Product\Option\Collection */ $this->_optionCollection->reset(); $this->_optionCollection->addProductToFilter($productIds); $this->_optionCollection->getSelect()->join(array('option_title' => $optionTitleTable), 'option_title.option_id = main_table.option_id', array('title' => 'title', 'store_id' => 'store_id'))->where('option_title.store_id = ?', $storeId); $this->_byPagesIterator->iterate($this->_optionCollection, $this->_pageSize, array($addCustomOptions)); } $this->_oldCustomOptions = $oldCustomOptions; } return $this; }
public function testReset() { $this->collection->reset(); }