preparePropertyData example

/** * @throws \Shopware\Components\Api\Exception\ValidationException * @throws Exception * * @return \Shopware\Models\Property\Group */
    public function create(array $params)
    {
        $this->checkPrivilege('create');

        $params = $this->preparePropertyData($params);

        $property = new \Shopware\Models\Property\Group();
        $property->fromArray($params);

        $violations = $this->getManager()->validate($property);
        if ($violations->count() > 0) {
            throw new ApiException\ValidationException($violations);
        }

        $this->getManager()->persist($property);
        $this->flush();

        
Home | Imprint | This part of the site doesn't use cookies.