/**
  * @param string | array $data              Product data submitted by form
  * @throws TransformationFailedException    Exception thrown if invalid type given
  *
  * @return Product                       Returns instance of Product object
  */
 public function reverseTransform($data)
 {
     $product = new Product($this->_locale, $this->_priceTypes, $this->_defaultCurrency, $this->_taxStrategy);
     $product->setName($data['name'])->setDisplayName($data['name'])->setBrand($data['brand'])->setCategory($data['category'])->setDescription($data['description'])->setType($this->_productTypes->get($data['type']));
     // setting prices
     foreach ($data['prices']['currencies'] as $currency => $typePrices) {
         foreach ($typePrices as $type => $price) {
             $product->setPrice($type, $currency, $price);
         }
     }
     // create the unit
     if (!empty($data['units'])) {
         foreach ($data['units'] as $unitData) {
             $unit = new Unit($this->_locale, $this->_priceTypes, $this->_defaultCurrency);
             $unit->setProduct($product);
             $unit->setSKU($unitData['sku']);
             $unit->setStockForLocation($unitData['stock'], $this->_defaultLocation);
             $unit->setVisible(true);
             $unit->revisionID = 1;
             foreach ($unitData['variants'] as $option) {
                 $unit->setOption($option['key'], $option['value']);
             }
             $product->addUnit($unit);
         }
     }
     return $product;
 }