@@ -18,47 +18,49 @@ class Helper
1818 */
1919 public static function generateProducts (
2020 int $ iterations ,
21+ array $ devices = ['iPhone ' , 'iPad ' , 'MacBook ' ],
2122 array $ colours = ['Blau ' , 'Rosa ' , 'Gold ' , 'Schwarz ' ],
2223 array $ storages = ['128GB ' , '256GB ' , '512GB ' ],
2324 ): array {
2425 $ products = [];
2526 $ id = 0 ;
2627 for ($ i = 1 ; $ i <= $ iterations ; $ i ++) {
27- foreach ($ colours as $ color ) {
28- foreach ($ storages as $ storage ) {
29- $ id ++;
30- $ product = new ProductBaseDto ((string ) $ id );
31- $ product ->setName ('iPhone ' . $ i . ' Pro ' . $ color . ' - ' . $ storage );
32- $ product ->setDescription (
33- 'The latest iPhone with advanced features. Color: ' . $ color . ', Storage: ' . $ storage . '. '
34- );
35- $ product ->setId ((string ) $ id );
36- $ product ->setOrdernumber ('AP-00 ' . $ i . '- ' . $ color . '- ' . $ storage );
37- $ product ->setPrice (1000 + $ id );
38- $ product ->setInstock (rand (0 , 50 ));
39- $ product ->setRating ((float ) (mt_rand (1 , 10 ) / 2 ));
40- $ product ->setManufacture ('Apple ' );
41- $ product ->setManufactureNumber ('A ' . $ i . '- ' . $ color . '- ' . $ storage );
42- $ product ->setEan ('195950639292 ' );
43- $ product ->setImageUrl (
44- 'https://dummyimage.com/600x400/bbb/fff.png&text= ' . $ i . '- ' . $ color . '- ' . $ storage
45- );
46- $ product ->setShopUrl ('https://www.apple.com/iphone-17-pro/ ' );
47- $ product ->setProperties (
48- (new ProductPropertyDto ())
49- ->addProperty ('Farbe ' , $ color )
50- ->addProperty ('Speicherkapazität ' , $ storage )
51- ->addProperty ('Displaygröße ' , '6,1 ' )
52- );
53- $ product ->addCategory (
54- (new CategoryDto ())->addCategoryNode ('Apple ' )->addCategoryNode ('iPhone ' )->addCategoryNode (
55- 'iPhone ' . $ i . ' Pro '
56- )
57- );
58- $ product ->addCategory (
59- (new CategoryDto ())->addCategoryNode ('Apple ' )->addCategoryNode ('iPhone Pro ' . $ color )
60- );
61- $ products [] = $ product ;
28+ foreach ($ devices as $ device ) {
29+ foreach ($ colours as $ color ) {
30+ foreach ($ storages as $ storage ) {
31+ $ id ++;
32+ $ product = new ProductBaseDto ((string ) $ id );
33+ $ product ->setName ($ device . ' ' . $ i . ' Pro ' . $ color . ' - ' . $ storage );
34+ $ product ->setDescription (
35+ 'The latest ' . $ device . ' with advanced features. Color: ' . $ color . ', Storage: ' . $ storage . '. '
36+ );
37+ $ product ->setId ((string ) $ id );
38+ $ product ->setOrdernumber ('AP-00 ' . $ i . '- ' . $ color . '- ' . $ storage );
39+ $ product ->setPrice (1000 + $ id );
40+ $ product ->setInstock (rand (0 , 50 ));
41+ $ product ->setRating ((float ) (mt_rand (1 , 10 ) / 2 ));
42+ $ product ->setManufacture ('Apple ' );
43+ $ product ->setManufactureNumber ('A ' . $ i . '- ' . $ color . '- ' . $ storage );
44+ $ product ->setEan ('195950639292 ' );
45+ $ product ->setImageUrl (
46+ 'https://dummyimage.com/600x400/bbb/fff.png&text= ' . $ i . '- ' . $ color . '- ' . $ storage
47+ );
48+ $ product ->setShopUrl ('https://www.apple.com/ ' . $ device . '- ' . $ i . '-pro/ ' );
49+ $ product ->setProperties (
50+ (new ProductPropertyDto ())
51+ ->addProperty ('Gerät ' , $ device )
52+ ->addProperty ('Farbe ' , $ color )
53+ ->addProperty ('Speicherkapazität ' , $ storage )
54+ ->addProperty ('Displaygröße ' , '6,1 ' )
55+ );
56+ $ product ->addCategory (
57+ (new CategoryDto ())->addCategoryNode ('Apple ' )->addCategoryNode ($ device )->addCategoryNode ($ device . ' ' . $ i . ' Pro ' )
58+ );
59+ $ product ->addCategory (
60+ (new CategoryDto ())->addCategoryNode ('Apple ' )->addCategoryNode ($ device . ' Pro ' . $ color )
61+ );
62+ $ products [] = $ product ;
63+ }
6264 }
6365 }
6466 }
0 commit comments