public function updateAction() { $stores = $this->getRequest()->getParam('stores'); $this->getCatalog('StoreHouseBylocationCatalog')->beginTransaction(); try { foreach ($stores as $store) { $storeByLocation = StoreHouseByLocationFactory::createFromArray($store); if (StoreHouseByLocationQuery::create()->whereAdd(StoreHouseByLocation::TYPE, $storeByLocation->getType())->whereAdd(StoreHouseByLocation::WHS_CODE_STORE_HOUSES_PPV, $storeByLocation->getWhsCodeStoreHousesPpv())->count()) { $storeByLocation->setIdStoreHouseByLocation(StoreHouseByLocationQuery::create()->whereAdd(StoreHouseByLocation::TYPE, $storeByLocation->getType())->whereAdd(StoreHouseByLocation::WHS_CODE_STORE_HOUSES_PPV, $storeByLocation->getWhsCodeStoreHousesPpv())->findOne()->getIdStoreHouseByLocation()); $this->getCatalog('StoreHouseBylocationCatalog')->update($storeByLocation); } else { $this->getCatalog('StoreHouseBylocationCatalog')->create($storeByLocation); } } } catch (Exception $e) { $this->setFlash('error', $e->getMessage()); $this->_redirect('store-house-by-location/list'); } $this->getCatalog('StoreHouseBylocationCatalog')->commit(); $this->setFlash('ok', $this->i18n->_('The changes has been saved')); $this->_redirect('store-house-by-location/list'); }
/** * * makeBean * @param array $resultset * @return \Application\Model\Bean\StoreHouseByLocation */ protected function makeBean($resultset) { return StoreHouseByLocationFactory::createFromArray($resultset); }