Добре, через деякий час я знайшов рішення у випадку, якщо комусь це потрібно. Магенто використовує інший підхід до створення об'єктів, традиційний спосіб інстанцізації об'єктів у Magento 1.x використовував "Mage :: getModel (..)", це змінилися в Magento 2. Тепер Magento використовує диспетчер об'єктів для створення об'єктів, я не буду вводити подробиці про те, як це працює .. так, еквівалентний код для створення клієнтів у Magento 2 виглядатиме так:
<?php
namespace ModuleNamespace\Module_Name\Controller\Index;
class Index extends \Magento\Framework\App\Action\Action
{
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $storeManager;
/**
* @var \Magento\Customer\Model\CustomerFactory
*/
protected $customerFactory;
/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Customer\Model\CustomerFactory $customerFactory
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Customer\Model\CustomerFactory $customerFactory
) {
$this->storeManager = $storeManager;
$this->customerFactory = $customerFactory;
parent::__construct($context);
}
public function execute()
{
// Get Website ID
$websiteId = $this->storeManager->getWebsite()->getWebsiteId();
// Instantiate object (this is the most important part)
$customer = $this->customerFactory->create();
$customer->setWebsiteId($websiteId);
// Preparing data for new customer
$customer->setEmail("email@domain.com");
$customer->setFirstname("First Name");
$customer->setLastname("Last name");
$customer->setPassword("password");
// Save data
$customer->save();
$customer->sendNewAccountEmail();
}
}
Сподіваюся, цей фрагмент коду допоможе комусь іншому ..