getCollection(); $collection->addFieldToFilter('path', $path); $collection->addFieldToFilter('scope', $scope); if($collection->count() > 0){ $model->load($collection->getFirstItem()->getId()); } } $model->setData('path', $path); $model->setData('value', $value); $model->setData('scope', $scope); $model->save(); } /** * Deletes an item or items depends on the given unique flag * * @param string $path * @param string|int $scope */ public function remove($path, $scope="", $unique=false){ $model = Mage::getModel('meecomframe/storage'); $collection = $model->getCollection(); $collection->addFieldToFilter('path', $path); if(strlen($scope) > 0) $collection->addFieldToFilter('scope', $scope); if($collection->count() > 0){ if($unique){ $item = $collection->getFirstItem()->getData('value'); $item->delete(); }else{ foreach($collection as $item){ $item->delete(); } } } } /** * Retrieves a storage * * @param string $path * @param string|int $scope * @param boolean $unique * @return MeetsEcommerce_Frame_Model_Mysql4_Storage_Collection|string */ public function get($path, $scope="", $unique=false){ $model = Mage::getModel('meecomframe/storage'); $collection = $model->getCollection(); $collection->addFieldToFilter('path', $path); if(strlen($scope) > 0) $collection->addFieldToFilter('scope', $scope); if($unique){ if($collection->count() > 0){ return $collection->getFirstItem()->getData('value'); }else{ return ''; } } return $collection; } }