/**
  * Prepares config data and checks different conditions like finished mapping.
  */
 protected function __construct()
 {
     //
     $this->Config = PlentymarketsConfig::getInstance();
     $this->StatusController = PlentymarketsExportStatusController::getInstance();
     // Check whether a process is running
     $this->isRunning = (bool) $this->Config->getIsExportRunning(false);
     // If the export is not complete
     if (!$this->isComplete()) {
         // the garbage collector will run
         PlentymarketsGarbageCollector::getInstance()->run(PlentymarketsGarbageCollector::ACTION_MAPPING);
     }
     // Check whether settings and mapping are done
     $this->mayRun = PlentymarketsStatus::getInstance()->mayExport();
 }
 /**
  * Resets a last update timestamp of an entity
  */
 public function resetImportTimestampAction()
 {
     $entity = $this->Request()->get('entity');
     if (in_array($entity, array('ItemStack', 'ItemPrice', 'ItemStock', 'ItemBundle'))) {
         PlentymarketsConfig::getInstance()->erase('Import' . $entity . 'LastUpdateTimestamp');
         PlentymarketsLogger::getInstance()->message('Sync:Reset', $entity . ' resetted');
     }
     // Cleanup the mapping – whatsoever
     PlentymarketsGarbageCollector::getInstance()->run(PlentymarketsGarbageCollector::ACTION_MAPPING);
     $this->View()->assign(array('success' => true, 'data' => $entity));
 }
 /**
  * Runs the item bundle cleanup cronjob.
  *
  * @param Shopware_Components_Cron_CronJob $Job
  */
 public function runItemBundleCleanup(Shopware_Components_Cron_CronJob $Job)
 {
     if (!$this->Status->maySynchronize()) {
         return;
     }
     PlentymarketsLogger::getInstance()->message('Cleanup:Item:Bundle', 'Starting');
     $PlentymarketsGarbageCollector = PlentymarketsGarbageCollector::getInstance();
     $PlentymarketsGarbageCollector->run(PlentymarketsGarbageCollector::ACTION_PRUNE_ITEM_BUNDLES);
     PlentymarketsLogger::getInstance()->message('Cleanup:Item:Bundle', 'Finished');
 }