3

I am using magento 1.7.0.2. I am having issue regarding store id. When I add new customer from front end by sign up it adds store id in "Customer Entity" table. But When I try to add customer from backend manually it doesn't insserts 'store id' in "Customer Entity" table.It inserss '0' when adding with admin.

1

It is simple. go to /app/code/core/Mage/Adminhtml/controllers/CustomerController.php and just before //send welcome email part

// Mage::dispatchEvent('adminhtml_customer_prepare_save', array(
//                    'customer'  => $customer,
//                    'request'   => $this->getRequest()
//                ));

And put following code there.

$storeId = $customer->getSendemailStoreId();
Mage::app()->setCurrentStore($storeId);
$customer->save(); 

That's it now you can choose store from backend and will also be inserted in to customer_entity table.

solution find from phprocks

  • Thanks its working properly.no need to hardcode. – Nilesh Aug 23 '13 at 10:30
1

I think that for admin created users Magento gets store id dynamically and uses websites default store. You can only set website to which a customer belongs.

1

The store ID just shows where the account was created. There's no way in the backend to change that value, from what I saw. You can, of course, change the value in the database, and it will reflect the change under the customer's "Personal Information" > "Account Created in:" in the backend view.

You can change the customer's store programmatically like so (not tested):

$customer = Mage::getModel('customer/customer')->loadByEmail($customer_email);
$customer->setStore(Mage::app()->getStore());
$customer->save();
  • Isn't its possible to set new field in backend add customer form to select store and insert store id in "Customer Entity" table in DB. – Nilesh Aug 22 '13 at 4:38
  • @Nilesh That is definitely possible with a small Magento extension. This article may be of some help. – twistedjames Aug 22 '13 at 12:05
  • Yes it works but it is for front end sign up form not for backend admin add customer form – Nilesh Aug 23 '13 at 5:39
0

For a Magento 1.4.1.1, I have done an overload module in order to modify the behaviour of this controller. But if in the file app/code/local/Aetaebc/Adminhtml/controllers/CustomerController.php In public function saveAction() I put:

// Mage::dispatchEvent('adminhtml_customer_prepare_save', array(
//                    'customer'  => $customer,
//                    'request'   => $this->getRequest()
//                ));

and

$storeId = $customer->getSendemailStoreId();
Mage::app()->setCurrentStore($storeId);
$customer->save(); 

as proposed by phprocks The store_id is good but it's impossible to send an email with a new password to the customer via the Magento backoffice.

So, for my usage, I decided to just force the $tore _Id value.

.../...
            Mage::dispatchEvent('adminhtml_customer_prepare_save',
                array('customer' => $customer, 'request' => $this->getRequest())
            );

            $storeId = 4; // force StoreId 
            Mage::app()->setCurrentStore($storeId); 

            $customer->save();
.../...

It's not ideal but it works .

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.