zoukankan      html  css  js  c++  java
  • Magento2 updated quote_item table

        /**
         * @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());
            }
        }
  • 相关阅读:
    两个数组的交集
    左叶子之和
    下载安装python
    占位
    2020 软件工程实践 助教总结
    安装使用 QEMU-KVM 虚拟化环境(Arch Linux / Manjaro / CentOS / Ubuntu )
    #69. 新年的QAQ
    1097E. Egor and an RPG game(Dilworth定理)
    #553. 【UNR #4】己酸集合
    #2099. 「CQOI2015」标识设计(插头dp)
  • 原文地址:https://www.cnblogs.com/q1104460935/p/10847588.html
Copyright © 2011-2022 走看看