public function ajaxAddAction(Request $request): Response
    {
        if (!$request->isXmlHttpRequest()) {
            return $this->redirectToAction('index');
        }
        
        $attributeName    = $request->request->get('name');
        $attributeGroupId = (int)$request->request->get('set');
        
        try {
            $attribute = $this->getManager()->createAttribute($attributeName, $attributeGroupId);
            
            return $this->jsonResponse([
                'id' => $attribute->getId(),
            ]);
            
        } catch (\Exception $e) {
            
            return $this->jsonResponse([
                'error' => $e->getMessage(),
            ]);
        }
    }
public function ajaxAddAction(Request $request): Response
    {
        if (!$request->isXmlHttpRequest()) {
            return $this->redirectToAction('index');
        }
        
        $attributeName    = $request->request->get('name');
        $attributeGroupId = (int)$request->request->get('set');
        
        try {
            $attribute = $this->getManager()->createAttribute($attributeName, $attributeGroupId);
            
            return $this->jsonResponse([
                'id' => $attribute->getId(),
            ]);
            
        } catch (\Exception $e) {
            
            return $this->jsonResponse([
                'error' => $e->getMessage(),
            ]);
        }
    }
public function ajaxAddAction ( Request $ request ) : Response { if ( ! $ request -> isXmlHttpRequest ( ) ) { return $ this -> redirectToAction ( 'index' ) ; } $ attributeName = $ request -> request -> get ( 'name' ) ; $ attributeGroupId = ( int ) $ request -> request -> get ( 'set' ) ; try { $ attribute = $ this -> getManager ( ) -> createAttribute ( $ attributeName , $ attributeGroupId ) ; return $ this -> jsonResponse ( [ 'id' => $ attribute -> getId ( ) , ] ) ; } catch ( \ Exception $ e ) { return $ this -> jsonResponse ( [ 'error' => $ e -> getMessage ( ) , ] ) ; } }
Adds new attribute value using ajax request

@param Request $request

@return Response
Adds new attribute value using ajax request