【发布时间】:2014-02-24 09:46:11
【问题描述】:
我尝试从产品中删除一个类别,但没有成功。 它仍然是该类别的产品。
这是我正在使用的代码:
$categories = array();
$categories[] = $this->erp['mastercat'];
if(isset($this->erp['article']['all_categories'])){
if(is_array($this->erp['article']['all_categories']) && count($this->erp['shop']['all_categories'])>0){
foreach($this->erp['article']['all_categories'] as $category){
if(!in_array($category,$categories)){
$categories[] = $category;
}
}
}else if(!empty($this->erp['article']['all_categories'])){
if(!in_array($this->erp['article']['all_categories'], $categories)){
$categories[] = $this->erp['article']['all_categories'];
}
}
}
$this->product->setCategoryIds($categories);
我正在使用一个空白数组,并且只将我需要的类别放入其中。
我不明白为什么选择了以前选择的类别和新的类别(我将它在我的 erp 中从一个类别移到另一个类别)。
【问题讨论】: