bombis Posted September 11, 2019 Share Posted September 11, 2019 Hello i am trying to assign group and make it the default group for the customer logged. This is what i tried $this->context->customer->addGroups(array(7)); $this->context->customer->id_default_group = 7; The group assign is doing good but the default is not changing. Any help? Thanks Link to comment Share on other sites More sharing options...
bombis Posted September 12, 2019 Author Share Posted September 12, 2019 Solved using querys.. $query = "UPDATE `"._DB_PREFIX_."customer` SET id_default_group = 7 WHERE id_customer=". $this->context->customer->id; Db::getInstance()->Execute($query); Prob. there is a better way to do it but i just needed a temporal solution for a week. Link to comment Share on other sites More sharing options...
EvaF Posted September 12, 2019 Share Posted September 12, 2019 (edited) maybe you should not forget $query ="INSERT IGNORE INTO `"._DB_PREFIX_."customer_group` (`id_customer`, `id_group`) values(id_customer=". $this->context->customer->id . ",7)"; Db::getInstance()->Execute($query); Edited September 12, 2019 by EvaF (see edit history) Link to comment Share on other sites More sharing options...
bombis Posted September 12, 2019 Author Share Posted September 12, 2019 (edited) 4 hours ago, EvaF said: maybe you should not forget $query ="INSERT IGNORE INTO `"._DB_PREFIX_."customer_group` (`id_customer`, `id_group`) values(id_customer=". $this->context->customer->id . ",7)"; Db::getInstance()->Execute($query); Thanks for your suggestion! Edited September 12, 2019 by bombis (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now