/** * 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; }
protected function _validate() { $_validationResult = parent::_validate(); if (!$_validationResult) { return false; } $attributesFlag = false; if ($attributes = $this->getAttributes()) { $attributesCount = 0; foreach ($attributes as $_attributeId => $_attributeValue) { if ($_attributeValue != '') { $attributesCount++; } } if ($attributesCount && $attributesCount <= self::DEFAULT_COUNT_OF_ATTRIBUTES) { $attributesFlag = true; } } if ($this->_validateEntryFlag && !$attributesFlag) { return false; } if (!$this->_validateEntryFlag && $attributesFlag) { return false; } return true; }
/** * 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; }
protected function _validate() { if ($this->getPageType() && $this->getPageType() == self::PAGE_TYPE_VARIANT) { if ($this->getTrackingScript()) { return true; } } return parent::_validate(); }
/** * Removing scripts assigned to entity * * @param integer $storeId * @return Mage_GoogleOptimizer_Model_Code */ public function deleteScripts($storeId) { $category = $this->getEntity(); if ($category) { /** * We need check category children ids */ $ids = $category->getDeletedChildrenIds(); if (is_array($ids)) { $ids[] = $category->getId(); } else { $ids = array($category->getId()); } $this->setEntityIds($ids); } return parent::deleteScripts($storeId); }