0

I am in the process of standing up a production server for new shop migrated from Magento 1.9.

Wholesale users go to site.dev/customer/account/create/group/wholesale?___store=wholesale_v (same for the staging environment, which is on the internet) and when they register via this form, it assigns them to the wholesale group. When they go to the same endpoint on my the production server, it assigns them to the General group. I'm at a loss and it seems every time I make any headway with any of these types of issues, another one specific only to the production server pops up.

Is there a different way I should be signing up customers to a specific group?

Has anyone come across this? All environments are running the same code base. The production server is hosted by Nexcess if that provides any clues.

Thanks very much!

0

Rather than messing around and spending hours troubleshooting, I did the following...

Based on this answer I created an observer. Except I'm listening to the custom_save_before event since I need to modify the customer before it's saved (I have a pending registration module installed).

class SaveBefore implements \Magento\Framework\Event\ObserverInterface
{
    protected $_request;
    private $customerRepository;

    public function __construct(
        \Magento\Framework\App\RequestInterface $request
    )
    {
        $this->_request = $request;
    }

    /**
     * Execute observer
     *
     * @param \Magento\Framework\Event\Observer $observer
     * @return void
     */
    public function execute(
        \Magento\Framework\Event\Observer $observer
    ) {
        $customer = $observer->getEvent()->getCustomer();
        $group = $this->_request->getParam('group');

        if ($group === 'wholesale') {
            $customer->setGroupId(2);
        }
    }
}

Now when a user wants to sign up for the wholesale group they go to /customer/account/create/?group=wholesale and the query param is passed along to the observer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.