Index: src/system/conf/export/export_variables.inc.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- src/system/conf/export/export_variables.inc.php (revision d63b712fe5a2d6a3da743cb2d44d3a91b47cf155) +++ src/system/conf/export/export_variables.inc.php (revision ) @@ -634,6 +634,11 @@ array( 'name' => 'p_google_product_group', 'product_export_forbidden' => true + ), + + array( + 'name' => 'automatic_mpn', + 'product_export_forbidden' => true ) )); Index: src/system/classes/csv/CSVFunctionLibrary.inc.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- src/system/classes/csv/CSVFunctionLibrary.inc.php (revision d63b712fe5a2d6a3da743cb2d44d3a91b47cf155) +++ src/system/classes/csv/CSVFunctionLibrary.inc.php (revision ) @@ -1911,4 +1911,59 @@ return $t_truncated_string; } + + + /** + * If 'identifier_exists' is true the mpn from Database will be returned. If there is no MPN in Database, + * System will generate one. + * + * @param $p_data_array + * + * @return string + */ + protected function automatic_mpn($p_data_array) + { + + $mpn_automatic = ''; + + $product_id = isset($p_data_array['products_id']) ? $p_data_array['products_id'] : 0; + + $query = 'SELECT `code_mpn`, `identifier_exists` FROM `products_item_codes` WHERE `products_id` = \'' + . $product_id . '\''; + + $result = xtc_db_query($query); + + $dataSet = xtc_db_fetch_array($result); + + $mpn = isset($dataSet['code_mpn']) ? $dataSet['code_mpn'] : ''; + $identifier_exists = isset($dataSet['identifier_exists']) ? $dataSet['identifier_exists'] : false; + + $identifier_exists = (bool)$identifier_exists; + + if($identifier_exists && $product_id !== '0') + { + $mpn_automatic = $mpn ? : $this->buildMpn($product_id); + } + + return $mpn_automatic; + } + + + /** + * @param $productId + * + * @return string + */ + protected function buildMpn($productId) + { + + $mpn_automatic = md5($productId); + $mpn_automatic = strtoupper($mpn_automatic); + + $mpn_automatic = preg_replace('/.{4}/', '$0.', $mpn_automatic); + + $mpn_automatic = (substr($mpn_automatic, -1, 1) === '.') ? substr($mpn_automatic, 0, -1) : $mpn_automatic; + + return $mpn_automatic; + } } \ No newline at end of file Index: src/lang/english/sections/_samples/export_schemes_variables.lang.inc.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- src/lang/english/sections/_samples/export_schemes_variables.lang.inc.php (revision d63b712fe5a2d6a3da743cb2d44d3a91b47cf155) +++ src/lang/english/sections/_samples/export_schemes_variables.lang.inc.php (revision ) @@ -347,5 +347,8 @@ 'p_google_unit_pricing_base_measure_description' => 'Base price unit measure e.g.: 100 g', 'p_google_product_group_title' => '[Google] Product group', - 'p_google_product_group_description' => 'Numeric identifier, to group multiple variants to on single product.' + 'p_google_product_group_description' => 'Numeric identifier, to group multiple variants to on single product.', + 'automatic_mpn_title' => '[Google] MPN of the product (automatically generated, if missing)', + + 'automatic_mpn_description' => 'Manufacturer Part Number (MPN). If \'Identifier exists\' is activated for an article, the MPN will be returned. If there is no MPN stored in the Database, the system will generate one.' ); Index: src/lang/german/sections/_samples/export_schemes_variables.lang.inc.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- src/lang/german/sections/_samples/export_schemes_variables.lang.inc.php (revision d63b712fe5a2d6a3da743cb2d44d3a91b47cf155) +++ src/lang/german/sections/_samples/export_schemes_variables.lang.inc.php (revision ) @@ -347,5 +347,9 @@ 'p_google_unit_pricing_base_measure_description' => 'Grundpreis Einheitsmaß', 'p_google_product_group_title' => '[Google] Produktgruppe', - 'p_google_product_group_description' => 'Numerische Kennzeichnung, um mehrere Varianten eines Artikels zu einem Produkt zu gruppieren.' + 'p_google_product_group_description' => 'Numerische Kennzeichnung, um mehrere Varianten eines Artikels zu einem Produkt zu gruppieren.', + + 'automatic_mpn_title' => '[Google] MPN des Produkts (automatisch generiert, wenn fehlend)', + 'automatic_mpn_description' => 'Manufacturer Part Number (MPN). Ist im Artikel \'Kennzeichnung existiert\' aktiviert, wird die hinterlegte Nummer ausgegeben. In dem Fall wird eine MPN generiert, wenn keine hinterlegt wurde.' + );