/** * Get the mapping data: vat * * @return array */ public function getVat() { $rows = Shopware()->Db()->query(' SELECT C.id, CONCAT(C.tax, " %") name, C.tax, IFNULL(PMC.plentyID, -1) plentyID FROM s_core_tax C LEFT JOIN plenty_mapping_vat PMC ON PMC.shopwareID = C.id ORDER BY C.tax ')->fetchAll(); $plentyVat = PlentymarketsImportController::getVatList(); foreach ($rows as &$row) { if ($row['plentyID'] >= 0) { $row['plentyName'] = $plentyVat[$row['plentyID']]['name']; } else { if ($this->auto) { $plentyVat = PlentymarketsImportController::getVatList(); foreach ($plentyVat as $plentyData) { list($name, $percent) = explode(' ', $plentyData['name']); if ((double) $row['tax'] == (double) $name) { $row['plentyName'] = $plentyData['name']; $row['plentyID'] = $plentyData['id']; PlentymarketsMappingController::addVat($row['id'], $plentyData['id']); break; } } } } } return $rows; }