Esempio n. 1
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();
 }