/** * @param $class * @return mixed */ public function mc_get_obj($class) { return MagentoFrameworkAppObjectManager::getInstance()->get($class); } /** * TODO UPDATE * @return bool|mixed */ public function update() { $customerId = $this->customerId; //fixme redirect login if (!$customerId) { //Todo @return not login $this->_die('not login', [], '/customer/account/login'); } //fixme get request $req = $this->setReq()->req; $o = $this->_o; $data = $req[$o]; /** * @var $quoteItem MagentoQuoteModelQuoteitem */ $quoteItem = $this->mc_get_obj('MagentoQuoteModelQuoteitem'); //req item id $item_id = $req[$o]['item_id']; //GET Quote id $item = $quoteItem->load($item_id); //GET Quote id $quoteId = $item->getQuoteId(); try { /** * @var $quote MagentoQuoteModelQuote */ $quote = $this->mc_get_obj(MagentoQuoteModelQuote::class)->load($quoteId); $item = $quote->getItemById($item_id); if (!$item) { var_dump('Item is empty !'); die; } $item->setSizeId($data['size_id']); $item->setSizeType($data['size_type']); $result = $item->save()->toArray(); $this->_die('Success !', [ 'size_id'=>$result['size_id'], 'size_type'=>$result['size_type'], ], '', 1); } catch (Exception $e) { $this->_die($e->getMessage()); } }