Magento 模型无法删除行

Magento model can't delete row

我正在尝试使用来自观察者的以下代码删除我的数据库 table 行。但无法删除它会在系统日志中给出错误

 Some transactions have not been committed or rolled back

$customFieldValue =  $this->_getRequest()->getPost();
             //$groupCodeArray = $customFieldValue['product']['customer_group_ids'];

             $DataCollectionDel = Mage::getModel('customerspecificproduct/customerspecificproduct')->getCollection()->addFieldToFilter(
                'product_ids',
                array(
                    'eq'=>$product->getId()
                )
            )->addFieldToFilter(
                'group_id',
                array(
                    'notnull'=>true,
                )
            );


            if($DataCollectionDel){
             foreach($DataCollectionDel as $data){
                    $deleteRow = Mage::getModel('customerspecificproduct/customerspecificproduct')->load($data->getId())->delete();

                }
             }exit;

我自己找到了解决方案

$DataCollectionDel = Mage::getModel('customerspecificproduct/customerspecificproduct')->getCollection()->addFieldToFilter(
                'product_ids',
                array(
                    'eq'=>$product->getId()
                )
            )->addFieldToFilter(
                'group_id',
                array(
                    'notnull'=>true,
                )
            );



             try{
                if($DataCollectionDel){
             foreach($DataCollectionDel as $data){
                    $data->delete();
                }
             }

我找到了解决方案 :3 没有 getCollection()。 型号

 public function deleteByCondition($itemId,$vendor)
    {
        return $this->getResource()->deleteByCondition($itemId,$vendor);
    }

资源模型

  public function deleteByCondition($itemId,$vendor)
    {
        $table = $this->getMainTable();
        $where = array();
        $where[] =  $this->_getWriteAdapter()->quoteInto('item_id = ?',$itemId);
        $where[] =  $this->_getWriteAdapter()->quoteInto("vendor = ? ", $vendor);
        $result = $this->_getWriteAdapter()->delete($table,$where);
        return $result;
    }