예제 #1
0
 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);
 }
예제 #2
0
 /**
  * @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);
 }
예제 #3
0
 /**
  * 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;
 }
예제 #4
0
파일: Full.php 프로젝트: nja78/magento2
 /**
  * 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];
 }
예제 #5
0
 /**
  * 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;
 }