public function handle(CreateBehaviorDO $do)
 {
     $entity = new Model();
     $entity->attributeSet()->associate($this->loadAttributeSetById($do->attribute_set_id));
     $entity->store()->associate($this->loadStoreById($do->store_id));
     $entity->save();
     if (count($do->values)) {
         foreach ($do->values as $valueDO) {
             $entity->values()->save($this->valueEntity(Model::OBJECT_TYPE, $valueDO));
         }
     }
 }
Example #2
0
 public function build(ProductModel $entity = null)
 {
     $do = new ProductDO();
     if ($entity) {
         $entityData = $entity->toArray();
         $entityData['attribute_set'] = $this->attributeSetBuilder->build($entity->attributeSet);
         if (count($entity->values)) {
             $entityData['values'] = $this->objectValueBuilder->buildThem($entity->values);
         }
         $do->update($entityData);
     }
     return $do;
 }