/** * Internal helper function to save the dynamic attributes of an article price. * @param $position * @param $attributeData * @return mixed */ private function savePositionAttributes($position, $attributeData) { if (empty($attributeData)) { return; } if ($position->getId() > 0) { $builder = Shopware()->Models()->createQueryBuilder(); $builder->select(array('attribute'))->from('Shopware\\Models\\Attribute\\OrderDetail', 'attribute')->where('attribute.orderDetailId = ?1')->setParameter(1, $position->getId()); $result = $builder->getQuery()->getOneOrNullResult(); if (empty($result)) { $attributes = new \Shopware\Models\Attribute\OrderDetail(); } else { $attributes = $result; } } else { $attributes = new \Shopware\Models\Attribute\OrderDetail(); } $attributes->fromArray($attributeData); $attributes->setOrderDetail($position); $this->getManager()->persist($attributes); }