Създаване на външен скрипт за импортиране на Quotes/Cart (друг CMS). Моят код може да добави оферта, но не и да създаде количка. Необходимо е всички цитирани артикули да се показват, когато потребителят влезе в своя акаунт. Активирах и постоянната количка.
class QuoteMove extends \Magento\Framework\App\Http implements \Magento\Framework\AppInterface
public function __construct(
\Magento\Framework\ObjectManagerInterface $objectManager,
\Magento\Framework\Event\Manager $eventManager,
\Magento\Framework\App\AreaList $areaList,
\Magento\Framework\App\Request\Http $request,
\Magento\Framework\App\Response\Http $response,
\Magento\Framework\ObjectManager\ConfigLoaderInterface $config,
\Magento\Framework\App\State $state,
\Magento\Framework\Filesystem $fileSystem,
\Magento\Framework\Registry $registry,
\Magento\Store\Model\Store $store,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\File\Csv $csvProcessor,
\Magento\Quote\Model\QuoteFactory $quote,
\Magento\Catalog\Model\Product $product
)
$quotes = [];
$email = [email protected];
$qty = xxx ;
$customerId = xxx ;
$this->customer = $this->getCustomerByEmail($email);
$customerId = $this->customer->getId();
$quote = $this->quotes[$customerId];
$quote->setCustomerNote(_NOTES_);
$quote->setCouponCode(_COUPON_CODE_);
$product = $this->_product->load('PRODUCT_ID'); //PRODUCT_ID= xx
$params = [];
$params['product'] = $productId;
$params['qty'] = intval($qty);
$options = [];
$options[_ATTRIBUTE_] = _VALUE_] ;
$params['super_attribute'] = $options;
$config = new \Magento\Framework\DataObject();
$config->setItem($params);
$quote->addProduct($product,$config);
$quote->save();
How to Save items in cart now ??
Така че, когато потребителят влезе в сметката, може да преглежда артикулите в количката.