Example #1
0
 /**
  * Also delete child table records when dropping this collection
  * @return integer
  */
 public function delete()
 {
     $this->ensureNotLocked();
     // !HOOK: additional functionality when deleting a collection
     if (isset($GLOBALS['ISO_HOOKS']['deleteCollection']) && is_array($GLOBALS['ISO_HOOKS']['deleteCollection'])) {
         foreach ($GLOBALS['ISO_HOOKS']['deleteCollection'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             $blnRemove = $objCallback->{$callback}[1]($this);
             if ($blnRemove === false) {
                 return 0;
             }
         }
     }
     $intPid = $this->id;
     $intAffectedRows = parent::delete();
     if ($intAffectedRows > 0 && $intPid > 0) {
         \Database::getInstance()->query("DELETE FROM " . \Isotope\Model\ProductCollectionItem::getTable() . " WHERE pid={$intPid}");
         \Database::getInstance()->query("DELETE FROM " . \Isotope\Model\Address::getTable() . " WHERE ptable='" . static::$strTable . "' AND pid={$intPid}");
     }
     $this->arrCache = array();
     $this->arrItems = null;
     $this->arrSurcharges = null;
     return $intAffectedRows;
 }