public function copyFolderContent($currentFolderGuid, $newCatalogGuid) { $tblCatalogFolder = new App_Model_Db_Table_CatalogFolder(); $rowset = $tblCatalogFolder->fetchAll("folderGuid = '{$currentFolderGuid}'"); if (count($rowset) > 0) { foreach ($rowset as $row) { $newContent = $tblCatalogFolder->createRow(); $newContent->folderGuid = $newCatalogGuid; $newContent->catalogGuid = $row->catalogGuid; $newContent->save(); } } }
public function save($aData) { if (empty($aData['profileGuid'])) { throw new Zend_Exception('Catalog Profile can not be EMPTY!'); } $tblCatalog = new App_Model_Db_Table_Catalog(); $gman = new Pandamp_Core_Guid(); $catalogGuid = isset($aData['guid']) && !empty($aData['guid']) ? $aData['guid'] : $gman->generateGuid(); $folderGuid = isset($aData['folderGuid']) && !empty($aData['folderGuid']) ? $aData['folderGuid'] : ''; //if not empty, there are 2 possibilities $where = $tblCatalog->getAdapter()->quoteInto('guid=?', $catalogGuid); if ($tblCatalog->fetchRow($where)) { $rowCatalog = $tblCatalog->find($catalogGuid)->current(); $rowCatalog->shortTitle = isset($aData['shortTitle']) ? $aData['shortTitle'] : $rowCatalog->shortTitle; $rowCatalog->publishedDate = isset($aData['publishedDate']) ? $aData['publishedDate'] : $rowCatalog->publishedDate; $rowCatalog->expiredDate = isset($aData['expiredDate']) ? $aData['expiredDate'] : $rowCatalog->expiredDate; $rowCatalog->status = isset($aData['status']) ? $aData['status'] : $rowCatalog->status; $rowCatalog->price = isset($aData['price']) ? $aData['price'] : $rowCatalog->price; } else { $rowCatalog = $tblCatalog->fetchNew(); $rowCatalog->guid = $catalogGuid; $rowCatalog->shortTitle = isset($aData['shortTitle']) ? $aData['shortTitle'] : ''; $rowCatalog->profileGuid = $aData['profileGuid']; $rowCatalog->publishedDate = isset($aData['publishedDate']) ? $aData['publishedDate'] : '0000-00-00 00:00:00'; $rowCatalog->expiredDate = isset($aData['expiredDate']) ? $aData['expiredDate'] : '0000-00-00 00:00:00'; $rowCatalog->createdBy = isset($aData['username']) ? $aData['username'] : ''; $rowCatalog->modifiedBy = $rowCatalog->createdBy; $rowCatalog->createdDate = date("Y-m-d h:i:s"); $rowCatalog->modifiedDate = $rowCatalog->createdDate; $rowCatalog->deletedDate = '0000-00-00 00:00:00'; $rowCatalog->status = isset($aData['status']) ? $aData['status'] : 0; $rowCatalog->price = isset($aData['price']) ? $aData['price'] : 0; } try { $catalogGuid = $rowCatalog->save(); } catch (Exception $e) { die($e->getMessage()); } $tableProfileAttribute = new App_Model_Db_Table_ProfileAttribute(); $profileGuid = $rowCatalog->profileGuid; $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $profileGuid); $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC'); $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute(); foreach ($rowsetProfileAttribute as $rowProfileAttribute) { if ($rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid)) { $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid); } else { $tblCatalogAttribute = new App_Model_Db_Table_CatalogAttribute(); $rowCatalogAttribute = $tblCatalogAttribute->fetchNew(); $rowCatalogAttribute->catalogGuid = $catalogGuid; $rowCatalogAttribute->attributeGuid = $rowProfileAttribute->attributeGuid; } $rowCatalogAttribute->value = isset($aData[$rowProfileAttribute->attributeGuid]) ? $aData[$rowProfileAttribute->attributeGuid] : ''; $rowCatalogAttribute->save(); } //save to table CatalogFolder only if folderGuid is not empty if (!empty($folderGuid)) { $tblCatalogFolder = new App_Model_Db_Table_CatalogFolder(); $rowsetCatalogFolder = $tblCatalogFolder->find($catalogGuid, $folderGuid); if (count($rowsetCatalogFolder) <= 0) { $rowCatalogFolder = $tblCatalogFolder->createRow(array('catalogGuid' => '', 'folderGuid' => '')); $rowCatalogFolder->catalogGuid = $catalogGuid; $rowCatalogFolder->folderGuid = $folderGuid; $rowCatalogFolder->save(); } } //do indexing $indexingEngine = Pandamp_Search::manager(); $indexingEngine->indexCatalog($catalogGuid); return $catalogGuid; }
public function copyToFolder($targetFolder) { $tblCatalogFolder = new App_Model_Db_Table_CatalogFolder(); $rowset = $tblCatalogFolder->find($this->guid, $targetFolder); if (count($rowset)) { //Catalog is already in the Target Folder.; } else { $row = $tblCatalogFolder->createRow(); $row->catalogGuid = $this->guid; $row->folderGuid = $targetFolder; try { $row->save(); return true; } catch (Exception $e) { throw new Zend_Exception($e->getMessage()); } } return false; }