/**
     * Get the mapping data: customer classes
     *
     * @return array
     */
    public function getCustomerClass()
    {
        $rows = Shopware()->Db()->query('
					SELECT
							C.id, description AS name,
							IFNULL(PMC.plentyID, -99) plentyID
						FROM s_core_customergroups C
						LEFT JOIN plenty_mapping_customer_class PMC
							ON PMC.shopwareID = C.id
						ORDER BY C.tax
				')->fetchAll();
        $plentyVat = PlentymarketsImportController::getCustomerClassList();
        foreach ($rows as &$row) {
            if (isset($plentyVat[$row['plentyID']])) {
                $row['plentyName'] = $plentyVat[$row['plentyID']]['name'];
            }
        }
        return $rows;
    }
 /**
  * Loads the plenty mapping data
  */
 public function getPlentyMappingDataAction()
 {
     $forceReload = $this->Request()->get('force', false);
     switch ($this->Request()->map) {
         case 'Country':
             $data = PlentymarketsConfig::getInstance()->getMiscCountriesSorted();
             break;
         case 'Currency':
             $data = PlentymarketsConfig::getInstance()->getMiscCurrenciesSorted();
             break;
         case 'MeasureUnit':
             $data = PlentymarketsConfig::getInstance()->getItemMeasureUnits();
             break;
         case 'Vat':
             if ($forceReload) {
                 PlentymarketsConfig::getInstance()->setMiscVatLastImport(0);
             }
             $data = PlentymarketsImportController::getVatList();
             break;
         case 'Referrer':
             if ($forceReload) {
                 PlentymarketsConfig::getInstance()->setMiscSalesOrderReferrerLastImport(0);
             }
             $data = PlentymarketsImportController::getOrderReferrerList();
             break;
         case 'ShippingProfile':
             if ($forceReload) {
                 PlentymarketsConfig::getInstance()->setMiscShippingProfilesLastImport(0);
             }
             $data = PlentymarketsImportController::getShippingProfileList();
             break;
         case 'MethodOfPayment':
             if ($forceReload) {
                 PlentymarketsConfig::getInstance()->setMiscMethodsOfPaymentLastImport(0);
             }
             $data = PlentymarketsImportController::getMethodOfPaymentList();
             break;
         case 'CustomerClass':
             if ($forceReload) {
                 PlentymarketsConfig::getInstance()->setMiscCustomerClassLastImport(0);
             }
             $data = PlentymarketsImportController::getCustomerClassList();
             break;
         case 'Shop':
             if ($forceReload) {
                 PlentymarketsConfig::getInstance()->setMiscMultishopsLastImport(0);
             }
             $data = PlentymarketsImportController::getStoreList();
             break;
         case 'OrderStatus':
         case 'PaymentStatus':
             if ($forceReload) {
                 PlentymarketsConfig::getInstance()->setMiscOrderStatusLastImport(0);
             }
             $data = PlentymarketsImportController::getOrderStatusList();
             foreach ($data as &$d) {
                 $d['id'] = $d['status'];
             }
             break;
     }
     $this->View()->assign(array('success' => true, 'data' => array_values($data)));
 }
 /**
  * Runs the mapping cleanup cronjob.
  *
  * @param Shopware_Components_Cron_CronJob $Job
  */
 public function runMappingCleanup(Shopware_Components_Cron_CronJob $Job)
 {
     // Check the connection
     if (!$this->Status->mayImport()) {
         return;
     }
     PlentymarketsLogger::getInstance()->message('Cleanup:Mapping', 'Starting');
     // Reset the timestamps
     PlentymarketsConfig::getInstance()->setMiscCustomerClassLastImport(0);
     PlentymarketsConfig::getInstance()->setMiscMethodsOfPaymentLastImport(0);
     PlentymarketsConfig::getInstance()->setMiscSalesOrderReferrerLastImport(0);
     PlentymarketsConfig::getInstance()->setMiscShippingProfilesLastImport(0);
     PlentymarketsConfig::getInstance()->setMiscMultishopsLastImport(0);
     PlentymarketsConfig::getInstance()->setMiscVatLastImport(0);
     // Get fresh data
     PlentymarketsImportController::getCustomerClassList();
     PlentymarketsImportController::getMethodOfPaymentList();
     PlentymarketsImportController::getOrderReferrerList();
     PlentymarketsImportController::getShippingProfileList();
     PlentymarketsImportController::getStoreList();
     PlentymarketsImportController::getVatList();
     PlentymarketsLogger::getInstance()->message('Cleanup:Mapping', 'Finished');
 }