Example #1
0
 /**
  * sets the settings for the committed shop
  */
 public function setSettingsAction()
 {
     $request = $this->Request();
     $trustedShopsParams = $request->getParams();
     /* @var TrustedShops $trustedShopsModel */
     $trustedShopsModel = $this->getModelManager()->getRepository('Shopware\\CustomModels\\TrustedShops\\TrustedShops')->findOneBy(array('shopId' => $trustedShopsParams['shopId']));
     if ($trustedShopsModel) {
         $trustedShopsModel->fromArray($trustedShopsParams);
     } else {
         $trustedShopsModel = new TrustedShops();
         $trustedShopsModel->fromArray($trustedShopsParams);
     }
     $this->getModelManager()->persist($trustedShopsModel);
     $this->getModelManager()->flush();
     $isExcellence = $this->getSoapApiComponent()->checkCertificateTypeIfExcellence($trustedShopsParams['shopId'], true);
     if (!$isExcellence) {
         $this->getSoapApiComponent()->deleteTrustedShopsArticles();
     }
     $this->View()->assign(array('data' => $trustedShopsParams['shopId'], 'success' => true));
 }
Example #2
0
 /**
  * gets the old data of the Trusted Shops core integration and the Trusted Shops Excellence plugin
  * and fills them into the new DB table of this plugin
  *
  * @param $pluginId
  */
 public function migrateData($pluginId)
 {
     $tsValues = $this->getTsClassicData();
     $tsExcValues = $this->getTsExcellenceData($pluginId);
     /** @var Repository $shopRepository */
     $shopRepository = $this->em->getRepository('Shopware\\Models\\Shop\\Shop');
     $shops = $shopRepository->getActiveShops();
     /** @var Shop $shop */
     foreach ($shops as $shop) {
         if (!$shop) {
             continue;
         }
         $shopId = $shop->getId();
         $oldTsId = $tsValues[$shopId];
         $oldTsEID = $tsExcValues['tsEID'][$shopId];
         $oldTsWebServiceUser = $tsExcValues['tsWebServiceUser'][$shopId];
         $oldTsWebServicePassword = $tsExcValues['tsWebServicePassword'][$shopId];
         $tsExcValues['testSystemActive'][$shopId] ? $oldTestSystemActive = $tsExcValues['testSystemActive'][$shopId] : ($oldTestSystemActive = 0);
         $tsExcValues['ratingActive'][$shopId] ? $oldRatingActive = $tsExcValues['ratingActive'][$shopId] : ($oldRatingActive = 1);
         /* @var TrustedShops $trustedShopsModel */
         $trustedShopsModel = $this->em->getRepository('Shopware\\CustomModels\\TrustedShops\\TrustedShops')->findOneBy(array('shopId' => $shopId));
         if (!$oldTsId && !$oldTsEID) {
             continue;
         }
         if (!$trustedShopsModel) {
             $trustedShopsModel = new TrustedShops();
             $trustedShopsModel->setShopId($shopId);
             $oldTsEID ? $trustedShopsModel->setTrustedShopsId($oldTsEID) : $trustedShopsModel->setTrustedShopsId($oldTsId);
             $trustedShopsModel->setTrustedShopsUser($oldTsWebServiceUser);
             $trustedShopsModel->setTrustedShopsPassword($oldTsWebServicePassword);
             $trustedShopsModel->setTrustedShopsTestSystem($oldTestSystemActive);
             $trustedShopsModel->setTrustedShopsShowRatingWidget($oldRatingActive);
             $trustedShopsModel->setTrustedShopsShowRatingsButtons(0);
             $trustedShopsModel->setTrustedShopsRateLaterDays(7);
         }
         $this->em->persist($trustedShopsModel);
         $this->em->flush();
     }
     $this->deactivateOldTsComponents();
 }