I am having problems when trying to add a new customer. I've tried the following but I am not sure if the name spacing is inaccurate?
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Customer\Model\Session $sessionSession,
\Magento\Customer\Model\Customer $customerModel,
array $data = []
) {
parent::__construct($context, $data);
$this->_customerSession = $sessionSession;
$this->customerModel = $customerModel;
}
public function createUser()
{
/** @var \Magento\Customer\Model\ $model */
$model = $this->customerModel;
$model->load($customerId);
$model->setName("James");
try{
$model->save();
}
catch(\Exception $e){
$this->systemHelper->setErrorMessage($e);
return false;
}
}
When I step over this the try/catch actually doesn't throw any errors?
die(var_dump($model));<--- Add this after you load the customer.Also, where are you setting
– Radosav Aug 30 '16 at 13:41$customerId? As far as i can see from your code, it's currently an empty variable, so model is not loading anything, therefore not saving anything.