0
votes

I am trying to update customer attribute in Shopware but getting error

$builder = $this->container->get('models')->createQueryBuilder()
                   ->update(\Shopware\Models\Customer\Customer::class, 'customer')
                   ->set('customer.active',0)
                   ->where('customer.email= :email')
                   ->setParameter('email ' ,'[email protected]');
        $builder->getQuery()->execute();

Fatal error: Uncaught Doctrine\ORM\Query\QueryException: Invalid parameter: token email is not defined in the query. in /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:134 Stack trace: #0 /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(362): Doctrine\ORM\Query\QueryException::unknownParameter('email ') #1 /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(319): Doctrine\ORM\Query->processParameterMappings(Array) #2 /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(962): Doctrine\ORM\Query->_doExecute() #3 /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(917): Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache(NULL, NULL) #4 /var/www/html/shopware/custom/plugins/CustomPlugin/Controllers/Frontend/CustomPlugin.php(17): Doctrine\ORM\AbstractQuery->execute() #5 /var/www/html/shopware/engine/Library/Enlight/Controller/Action.php(193): Shopware_Controllers_Frontend_CustomPlugin->indexAction() # in /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php on line 134

1

1 Answers

1
votes
  • Try to use where statement like this;

    ->where('customer.email = ?1')->setParameter(1 ,'[email protected]');