Я пытаюсь обновить атрибут клиента в Shopware, но получаю ошибку

Я пытаюсь обновить атрибут клиента в Shopware, но получаю ошибку

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

Фатальная ошибка: Uncaught Doctrine \ ORM \ Query \ QueryException: Invalid
параметр: токен электронной почты не определен в запросе. в
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:134
Трассировка стека: # 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 () # в
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php
по линии 134

0

Решение

  • Попробуйте использовать где утверждение, как это;

    ->where('customer.email = ?1')->setParameter(1 ,'xyz@test.com');
    
1

Другие решения

Других решений пока нет …