/**
  * Save data to product export table, create new row if not exists
  *
  * @throws \LogicException
  *
  * @return Edit
  */
 protected function _saveProductExport()
 {
     if (!$this->_product) {
         throw new \LogicException('Cannot edit product export info as no product is set');
     }
     $this->_trans->add("\n\t\t\tINSERT INTO\n\t\t\t\tproduct_export\n\t\t\t\t(\n\t\t\t\t\tproduct_id,\n\t\t\t\t\tlocale,\n\t\t\t\t\texport_value,\n\t\t\t\t\texport_description,\n\t\t\t\t\texport_manufacture_country_id,\n\t\t\t\t\texport_code\n\t\t\t\t)\n\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t:productID?i,\n\t\t\t\t\t:locale?sn,\n\t\t\t\t\t:exportValue?fn,\n\t\t\t\t\t:exportDescription?sn,\n\t\t\t\t\t:exportCountryID?s,\n\t\t\t\t\t:exportCode?sn\n\t\t\t\t)\n\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\texport_value\t\t\t\t\t= :exportValue?fn,\n\t\t\t\texport_description\t\t\t\t= :exportDescription?sn,\n\t\t\t\texport_manufacture_country_id\t= :exportCountryID?s,\n\t\t\t\texport_code                     = :exportCode?sn\n\t\t", ['productID' => $this->_product->id, 'locale' => $this->_locale->getID(), 'exportValue' => $this->_product->exportValue, 'exportDescription' => $this->_product->exportDescription, 'exportCountryID' => $this->_product->exportManufactureCountryID, 'exportCode' => $this->_product->getExportCode()]);
     return $this;
 }
 public function build(Product\Product $product)
 {
     $this->setName('product-details-edit')->setAction($this->_container['routing.generator']->generate('ms.commerce.product.edit.attributes.action', ['productID' => $product->id]))->setMethod('post');
     $this->add('name', 'text', $this->_trans('ms.commerce.product.attributes.name.label'), ['data' => $product->name, 'attr' => ['data-help-key' => 'ms.commerce.product.attributes.name.help']])->val()->maxLength(255);
     $this->add('display_name', 'text', $this->_trans('ms.commerce.product.attributes.display-name.label'), ['data' => $product->displayName, 'attr' => ['data-help-key' => 'ms.commerce.product.attributes.display-name.help']])->val()->optional()->maxLength(255);
     $this->add('sort_name', 'text', $this->_trans('ms.commerce.product.attributes.sort-name.label'), ['data' => $product->sortName, 'attr' => ['data-help-key' => 'ms.commerce.product.attributes.sort-name.help']])->val()->optional()->maxLength(255);
     $this->add('category', 'datalist', $this->_trans('ms.commerce.product.attributes.category.label'), ['choices' => $this->_getCategories(), 'data' => $product->category, 'attr' => ['data-help-key' => 'ms.commerce.product.attributes.category.help']]);
     $this->add('brand', 'datalist', $this->_trans('ms.commerce.product.attributes.brand.label'), ['data' => $product->brand, 'choices' => $this->_getBrands(), 'attr' => ['data-help-key' => 'ms.commerce.product.attributes.brand.help']])->val()->maxLength(255)->optional();
     $this->add('description', 'textarea', $this->_trans('ms.commerce.product.attributes.description.label'), ['data' => $product->description, 'attr' => ['data-help-key' => 'ms.commerce.product.attributes.description.help']])->val()->optional();
     $this->add('short_description', 'textarea', $this->_trans('ms.commerce.product.attributes.short-description.label'), ['data' => $product->shortDescription, 'attr' => ['data-help-key' => 'ms.commerce.product.attributes.short-description.help']])->val()->optional();
     $this->add('export_description', 'textarea', $this->_trans('ms.commerce.product.attributes.export-description.label'), ['data' => $product->exportDescription, 'attr' => ['data-help-key' => 'ms.commerce.product.attributes.export-description.help']])->val()->optional();
     $this->add('export_code', 'text', $this->_container['translator']->trans('ms.commerce.product.details.export-code.label'), ['data' => $product->getExportCode(), 'attr' => ['data-help-key' => 'ms.commerce.product.details.export-code.help']])->val()->optional();
     $this->add('supplier_ref', 'text', $this->_trans('ms.commerce.product.details.supplier-ref.label'), ['data' => $product->supplierRef, 'attr' => ['data-help-key' => 'ms.commerce.product.details.supplier-ref.help']])->val()->maxLength(255)->optional();
     $this->add('weight_grams', 'number', $this->_trans('ms.commerce.product.details.weight-grams.label'), ['data' => $product->weight, 'attr' => ['data-help-key' => 'ms.commerce.product.details.weight-grams.help']])->val()->number()->optional();
     $this->add('tags', 'textarea', $this->_trans('ms.commerce.product.details.tags.label'), ['data' => implode(', ', $product->tags), 'attr' => ['data-help-key' => 'ms.commerce.product.details.tags.help']])->val()->optional();
     $this->add('notes', 'textarea', $this->_trans('ms.commerce.product.details.notes.label'), ['data' => $product->notes, 'attr' => ['data-help-key' => 'ms.commerce.product.details.notes.help']])->val()->optional();
     $this->add('export_manufacture_country_id', 'choice', $this->_container['translator']->trans('ms.commerce.product.details.export-manufacture-country.label'), ['data' => $product->exportManufactureCountryID, 'choices' => $this->_container['country.list']->all(), 'attr' => ['data-help-key' => 'ms.commerce.product.details.export-manufacture-country.help']]);
     $typeChoices = [];
     foreach ($this->_container['product.types'] as $type) {
         $typeChoices[$type->getName()] = $type->getDisplayName();
     }
     $this->add('product_type', 'choice', $this->_container['translator']->trans('ms.commerce.product.details.product-type.label'), ['data' => $product->type->getName(), 'choices' => $typeChoices, 'attr' => ['data-help-key' => 'ms.commerce.product.details.product-type.help']]);
     return $this;
 }