public function buildForm(Form\FormBuilderInterface $builder, array $options)
 {
     $builder->add('name', 'text', ['label' => 'ms.commerce.product.create.name.label', 'attr' => ['placeholder' => $this->_trans->trans('ms.commerce.product.create.name.placeholder')], 'constraints' => [new Constraints\NotBlank()]])->add('brand', 'text', ['label' => 'ms.commerce.product.create.brand.label', 'attr' => ['placeholder' => $this->_trans->trans('ms.commerce.product.create.brand.placeholder')]])->add('category', 'text', ['label' => 'ms.commerce.product.create.category.label', 'attr' => ['placeholder' => $this->_trans->trans('ms.commerce.product.create.category.placeholder')], 'constraints' => [new Constraints\NotBlank()]])->add('units', 'collection', ['type' => 'product_unit', 'allow_add' => true, 'prototype_name' => '__unit__', 'label' => false, 'constraints' => [new Constraints\NotBlank()]]);
     $prices = $builder->create('prices', 'price_form', ['constraints' => [new Constraints\NotBlank()]]);
     $builder->add($prices)->add('description', 'textarea', ['label' => 'ms.commerce.product.create.description.label', 'attr' => ['placeholder' => $this->_trans->trans('ms.commerce.product.create.description.placeholder')]])->add('type', 'choice', ['label' => 'ms.commerce.product.attributes.type.label', 'choices' => $this->_productTypes->getList(), 'constraints' => [new Constraints\NotBlank()]]);
     return $this;
 }
 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);
 }