/** * Get the mapping data: country * * @return array */ public function getCountry() { $autodata = array('Großbritannien' => 'England', 'Slowakei' => 'Slowakische Republik', 'Rumänien' => 'Rumänien'); $rows = Shopware()->Db()->query(' SELECT C.id, C.countryname name, IFNULL(PMC.plentyID, 0) plentyID FROM s_core_countries C LEFT JOIN plenty_mapping_country PMC ON PMC.shopwareID = C.id ORDER BY C.countryname ')->fetchAll(); $plentyCountries = PlentymarketsConfig::getInstance()->getMiscCountries(); foreach ($rows as &$row) { if ($row['plentyID']) { $row['plentyName'] = $plentyCountries[$row['plentyID']]['name']; } else { if ($this->auto) { foreach ($plentyCountries as $plentyData) { if (isset($autodata[$row['name']])) { $shopwareName = $autodata[$row['name']]; } else { $shopwareName = $row['name']; } $distance = levenshtein($shopwareName, $plentyData['name']); if ($distance <= 2 || strstr($plentyData['name'], $shopwareName)) { $row['plentyName'] = $plentyData['name']; $row['plentyID'] = $plentyData['id']; PlentymarketsMappingController::addCountry($row['id'], $plentyData['id']); if ($distance == 0) { break; } } } } else { $row['plentyName'] = ''; } } } return $rows; }