public function testFactory() { $product = new \Magento\Framework\Object(); $product->setTypeId(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE); $type = $this->_productType->factory($product); $this->assertInstanceOf('\\Magento\\GroupedProduct\\Model\\Product\\Type\\Grouped', $type); }
/** * @param sring|null $typeId * @dataProvider factoryReturnsSingletonDataProvider */ public function testFactoryReturnsSingleton($typeId) { $product = new \Magento\Framework\Object(); if ($typeId) { $product->setTypeId($typeId); } $type = $this->_productType->factory($product); $otherType = $this->_productType->factory($product); $this->assertSame($otherType, $type); }
/** * Retrieve Product Type Instances * as key - type code, value - instance model * * @return array */ protected function _getProductTypeInstances() { if ($this->_productTypes === null) { $this->_productTypes = []; $productEmulator = new \Magento\Framework\Object(); foreach (array_keys($this->_productType->getTypes()) as $typeId) { $productEmulator->setTypeId($typeId); $this->_productTypes[$typeId] = $this->_productType->factory($productEmulator); } } return $this->_productTypes; }
/** * Retrieve Product Emulator (Magento Object) * * @param string $typeId * @return \Magento\Framework\Object */ protected function getProductEmulator($typeId) { if (!isset($this->productEmulators[$typeId])) { $productEmulator = new \Magento\Framework\Object(); $productEmulator->setTypeId($typeId); $this->productEmulators[$typeId] = $productEmulator; } return $this->productEmulators[$typeId]; }
/** * Retrieve Product Type Instances * as key - type code, value - instance model * * @return array */ public function getProductTypeInstances() { if (empty($this->_productTypes)) { $productEmulator = new \Magento\Framework\Object(); foreach (array_keys($this->_productType->getTypes()) as $typeId) { $productEmulator->setTypeId($typeId); $this->_productTypes[$typeId] = $this->_productType->factory($productEmulator); } } return $this->_productTypes; }