保存订单提示找不到setData方法

1.28K 浏览故障排除m2

保存订单提示找不到setData方法

Error: Call to undefined method User\Level\Model\ResourceModel\Discount\Collection\Interceptor::setData() in D:\phpstudy_pro\WWW\asteria2\app\code\User\Level\Model\Discount.php:361
$data1 = [
    'customer_id' => $customerId,
    'type' => Status::COUPONS,
    'point' => $couponData['points'],
    'value' => str_replace(array('$', '%'), '', $couponData['title']),
    'detail' =>  $couponData['value'],
    'code' => $couponData['code'],
    'style' => $couponData['type'],
    'month' => date('m'),
    'product_type' => $couponData['product_type'],
    'activity_time' => $this->getActivityTime(),
    'created' => $this->_helper->now(),
];
$discountgift =$this->_discountCollectionFactory->create();
$discountgift->setData($data1);
$discountgift->save();

这个是怎么回事呢?
已回答
0

用 User\Level\Model\ResourceModel\Discount这个model类来save, Discount\Collection是数据集 不能单个保存

已回答
0