how can I fill the DB with dummy data?
-
I created Categories in a seeder this way
-
And this is the Product seeder
public function run() { $faker = \Faker\Factory::create(); $product_repo = new \Webkul\Product\Repositories\ProductRepository( new AttributeRepository(new AttributeOptionRepository(app()), app()), new AttributeOptionRepository(app()), new ProductAttributeValueRepository(new AttributeRepository(new AttributeOptionRepository(app()), app()), app()), new ProductInventoryRepository(app()), new ProductImageRepository(app()), app() ); $product_inv_repo = new ProductInventoryRepository(app()); $categories = \App\Category::where('id', '!=', 1)->get()->pluck('id'); for ($i = 0; $i < 2500; $i++){ $product = $product_repo->create([ 'type' => 'simple', 'attribute_family_id' => 1, 'sku' => $faker->slug(2) ]); $product_repo->updateVariant([ 'sku' => $faker->uuid, 'name' => $faker->words(3, true), 'channel' => 'default', 'status' => 1, 'price' => rand(200, 90000), 'weight' => rand(200, 90000), 'locale' => 'en', 'url_key' => $faker->slug, 'new' => rand(0, 1), 'featured' => rand(0, 1), 'visible_individually' => 1, 'color' => rand(1, 3), 'size' => 5, 'short_description' => $faker->words(5, true), 'description' => $faker->words(45, true), 'meta_title' => $faker->words(2, true), 'meta_keywords' => implode(',', $faker->words(45)), 'meta_description' => $faker->words(45, true), ], $product->id); $product_repo->update( [ 'categories' => $categories [ rand(0, count($categories) - 1) ], ], $product->id, false, true ); $product_inv_repo->saveInventories([ 'inventories' => [ 1 => rand(10, 1000) ], ], $product); $product_repo->getProductImageRepository()->uploadImages([ 'images' => [ 'image_1' => $faker->image(), 'image_2' => $faker->image(), 'image_3' => $faker->image(), ], ], $product, true); ProductFlat::whereProductId($product->id) ->update([ 'url_key' => $faker->slug, 'new' => rand(0, 1), 'featured' => rand(0, 1), 'visible_individually' => 1, 'color' => rand(1, 3), 'size' => 5, 'channel' => 'default', 'locale' => 'en', 'short_description' => $faker->words(5, true), 'description' => $faker->words(45, true), 'meta_title' => $faker->words(2, true), 'meta_keywords' => implode(',', $faker->words(45)), 'meta_description' => $faker->words(45, true), ]); echo $i . PHP_EOL; } }
-
College Term Paper Services
Custom Term Paper Service industry has grown steadily in provision of Legitimate Term Paper Services and high quality Custom Term Paper Writing Services which is preferred by scholars worldwide.
https://researchpapers247.com/custom-term-paper-writing-service/ -
@alkhachatryan said in how can I fill the DB with dummy data?:
$product_repo = new \Webkul\Product\Repositories\ProductRepository(
new AttributeRepository(new AttributeOptionRepository(app()), app()),
new AttributeOptionRepository(app()),
new ProductAttributeValueRepository(new AttributeRepository(new AttributeOptionRepository(app()), app()), app()),
new ProductInventoryRepository(app()),
new ProductImageRepository(app()),
app()
);error
Argument 2 passed to Webkul\Product\Repositories\ProductRepository::__construct() must be an instance of Illuminate\Container\Container, instan
ce of Webkul\Attribute\Repositories\AttributeOptionRepository given, called in D:\laragon\www\ecom\database\seeds\ProductSeeder.php on line 30 -
Hi @nikul,
Please check your arguments which you have passed in the constructor.
-
@nikul did you find a solution to this?
-
@devansh-webkul got the same issue can and I checked, everything is passed successfully any idea how to fix it?
-
Hi @yiara,
I am not getting this, what he is trying to do. I just answered the error which he caused.
If you want help then first elaborate on what you are trying to do and the implementation steps.
So that I can further check.
-
I tried the above steps to import dummy data in my database, I got the same issue as this
Argument 2 passed to Webkul\Product\Repositories\ProductRepository::__construct() must be an instance of Illuminate\Container\Container, instan ce of Webkul\Attribute\Repositories\AttributeOptionRepository given, called in D:\laragon\www\ecom\database\seeds\ProductSeeder.php on line 30
regardless that I checked the arguments I passed in the instructor and everything is fine
-
So your issue is resolved now.