Magento2 updated quote_item table - 更新quote_item 表自定义字段
2024-09-06 21:06:34
/**
* @param $class
* @return mixed
*/ public function mc_get_obj($class)
{
return \Magento\Framework\App\ObjectManager::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 \Magento\Quote\Model\Quote\item
*/
$quoteItem = $this->mc_get_obj('Magento\Quote\Model\Quote\item');
//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 \Magento\Quote\Model\Quote
*/
$quote = $this->mc_get_obj(\Magento\Quote\Model\Quote::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());
}
}
最新文章
- dma_ops
- MVC 单元测试
- 关于提高python程序执行效率的思路和想法
- PHP mysqli 扩展库(面向对象/数据库操作封装/事务控制/预编译)
- To Use Ubuntuubunt
- 我的第一个python爬虫程序
- Play - js/css concatenation &; minify
- Selenium关于Page Objects
- css挖坑爬坑之div高宽相等
- studio中碰到的jni问题:java.lang.UnsatisfiedLinkError
- 7.首页、bitmaputils
- web应用 与 http协议
- SQLITE在IIS中使用问题
- IDAPython安装
- 2018-2019 2 20165203 《网络对抗技术》Exp5 MSF基础
- 【转载】Qt中图像的显示与基本操作
- Course List for Student
- Convolutional Networks for Images,Speech,and Time-series
- 一个exception
- Java -- 新IO -- 目录
热门文章
- 函数调用约定_stdcall[转]
- ELK同步kafka带有key的Message
- pytorch之 compare with numpy
- Kafka运维大全来了!优化、监控、故障处理……
- Zookeeper 应用实例
- Arm开发板+Qt学习之路-开发板显示 /bin/sh: ./hello: Permission denied
- js—DOM详情
- JAVA架构之单点登录 任务调度 权限管理 性能优化大型项目实战
- SAP 如何看某个TR是否传入了Q或者P系统?
- 【POJ - 2533】Longest Ordered Subsequence (最长上升子序列 简单dp)