private function _addProductType(array $data) { foreach ($this->_fieldCrawler->getTypeFields() as $type => $fields) { $typeSet = (bool) $this->_product->type; foreach ($fields as $name) { if (!empty($data[$name])) { if ($typeSet) { throw new \LogicException('Product type has been set to `' . $this->_product->type->getDisplayName() . '`, but contains data that belongs to the `' . $this->_productTypes->get($type)->getDisplayName() . '` product type'); } $productType = $this->_productTypes->get($type); $this->_product->type = $productType; $this->_setDetails($data); return; } } } $this->_product->type = $this->_productTypes->getDefault(); }
protected function _loadType(Product $product, $type) { $product->type = $this->_productTypes->get($type); }