<?php
|
|
namespace app\operations\controller\product;
|
|
use app\common\model\product\ProductCategory as ProductCategoryModel;
|
|
/**
|
* 商品多分类模型
|
*/
|
class ProductCategory extends ProductCategoryModel
|
{
|
/**
|
* 添加商品分类关系记录
|
*/
|
public function addCategoryList($product_id, $category_ids)
|
{
|
$data = [];
|
$model = new self;
|
foreach ($category_ids as $item) {
|
$data[] = [
|
'product_id' => $product_id,
|
'category_id' => $item,
|
'app_id' => self::$app_id,
|
];
|
}
|
count($data) > 0 && $model->saveAll($data);
|
}
|
|
/**
|
* 移除指定商品的所有分类
|
*/
|
public function removeAll($product_id)
|
{
|
$model = new self;
|
return $model->where('product_id','=', $product_id)->delete();
|
}
|
|
}
|