Example #1
0
 /**
  * Delete scripts by entity and store
  *
  * @param Mage_GoogleOptimizer_Model_Code $object
  * @param integer $store_id
  * @return Mage_GoogleOptimizer_Model_Resource_Code
  */
 public function deleteByEntityType($object, $store_id)
 {
     $adapter = $this->_getWriteAdapter();
     $entityIds = $object->getEntityIds();
     if (!empty($entityIds)) {
         $where[$this->getMainTable() . '.entity_id IN (?)'] = $entityIds;
     } else {
         $where[$this->getMainTable() . '.entity_id=?'] = $object->getEntity()->getId();
     }
     $where[$this->getMainTable() . '.entity_type=?'] = $object->getEntityType();
     $where[$this->getMainTable() . '.store_id=?'] = $store_id;
     $adapter->delete($this->getMainTable(), $where);
     $this->_afterDelete($object);
     return $this;
 }
Example #2
0
 /**
  * Delete scripts by entity and store
  *
  * @param Mage_GoogleOptimizer_Model_Code $object
  * @param integer $store_id
  * @return Mage_GoogleOptimizer_Model_Mysql4_Code
  */
 public function deleteByEntityType($object, $store_id)
 {
     $write = $this->_getWriteAdapter();
     if ($write) {
         $entityIds = $object->getEntityIds();
         if (!empty($entityIds)) {
             $where = $write->quoteInto($this->getMainTable() . '.entity_id IN (?)', $entityIds);
         } else {
             $where = $write->quoteInto($this->getMainTable() . '.entity_id=?', $object->getEntity()->getId());
         }
         $where .= ' AND ' . $write->quoteInto($this->getMainTable() . '.entity_type=?', $object->getEntityType()) . ' AND ' . $write->quoteInto($this->getMainTable() . '.store_id=?', $store_id);
         $write->delete($this->getMainTable(), $where);
     }
     $this->_afterDelete($object);
     return $this;
 }