Projekt

Allgemein

Profil

GX-Abgewiesen #40733 » 40733_Im_neuen_CSV_Export_können_keine_fehlenden_MPN_generiert_werden___Automatic_MPN_kan_1.patch

Jörg Wrase, 29.06.2015 16:27

Unterschiede anzeigen:

src/system/conf/export/export_variables.inc.php (revision )
634 634
	array(
635 635
		'name' => 'p_google_product_group',
636 636
		'product_export_forbidden' => true
637
	),
638

  
639
	array(
640
		'name' => 'automatic_mpn',
641
		'product_export_forbidden' => true
637 642
	)
638 643
	
639 644
));
src/system/classes/csv/CSVFunctionLibrary.inc.php (revision )
1911 1911
		
1912 1912
		return $t_truncated_string;
1913 1913
	}
1914

  
1915

  
1916
	/**
1917
	 * If 'identifier_exists' is true the mpn from Database will be returned. If there is no MPN in Database,
1918
	 * System will generate one.
1919
	 *
1920
	 * @param $p_data_array
1921
	 *
1922
	 * @return string
1923
	 */
1924
	protected function automatic_mpn($p_data_array)
1925
	{
1926

  
1927
		$mpn_automatic = '';
1928

  
1929
		$product_id = isset($p_data_array['products_id']) ? $p_data_array['products_id'] : 0;
1930

  
1931
		$query = 'SELECT `code_mpn`, `identifier_exists` FROM `products_item_codes` WHERE `products_id` = \''
1932
		         . $product_id . '\'';
1933

  
1934
		$result = xtc_db_query($query);
1935

  
1936
		$dataSet = xtc_db_fetch_array($result);
1937

  
1938
		$mpn               = isset($dataSet['code_mpn']) ? $dataSet['code_mpn'] : '';
1939
		$identifier_exists = isset($dataSet['identifier_exists']) ? $dataSet['identifier_exists'] : false;
1940

  
1941
		$identifier_exists = (bool)$identifier_exists;
1942

  
1943
		if($identifier_exists && $product_id !== '0')
1944
		{
1945
			$mpn_automatic = $mpn ? : $this->buildMpn($product_id);
1946
		}
1947

  
1948
		return $mpn_automatic;
1949
	}
1950

  
1951

  
1952
	/**
1953
	 * @param $productId
1954
	 *
1955
	 * @return string
1956
	 */
1957
	protected function buildMpn($productId)
1958
	{
1959

  
1960
		$mpn_automatic = md5($productId);
1961
		$mpn_automatic = strtoupper($mpn_automatic);
1962

  
1963
		$mpn_automatic = preg_replace('/.{4}/', '$0.', $mpn_automatic);
1964

  
1965
		$mpn_automatic = (substr($mpn_automatic, -1, 1) === '.') ? substr($mpn_automatic, 0, -1) : $mpn_automatic;
1966

  
1967
		return $mpn_automatic;
1968
	}
1914 1969
}
src/lang/english/sections/_samples/export_schemes_variables.lang.inc.php (revision )
347 347
	'p_google_unit_pricing_base_measure_description' => 'Base price unit measure e.g.: 100 g',
348 348
	
349 349
	'p_google_product_group_title' => '[Google] Product group',
350
	'p_google_product_group_description' => 'Numeric identifier, to group multiple variants to on single product.'
350
	'p_google_product_group_description' => 'Numeric identifier, to group multiple variants to on single product.',
351
	'automatic_mpn_title' => '[Google] MPN of the product (automatically generated, if missing)',
352
	
353
	'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.'
351 354
);
src/lang/german/sections/_samples/export_schemes_variables.lang.inc.php (revision )
347 347
	'p_google_unit_pricing_base_measure_description' => 'Grundpreis Einheitsmaß',
348 348
	
349 349
	'p_google_product_group_title' => '[Google] Produktgruppe',
350
	'p_google_product_group_description' => 'Numerische Kennzeichnung, um mehrere Varianten eines Artikels zu einem Produkt zu gruppieren.'
350
	'p_google_product_group_description' => 'Numerische Kennzeichnung, um mehrere Varianten eines Artikels zu einem Produkt zu gruppieren.',
351

  
352
	'automatic_mpn_title'       => '[Google] MPN des Produkts (automatisch generiert, wenn fehlend)',
353
	'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.'
354

  
351 355
);
(2-2/2)