From 1e2583b42180e8c2645eca62f0c116e1db8c2d88 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Thu, 12 Jan 2023 19:26:44 +0800 Subject: [PATCH] add attribute seeder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 创建属性组 产品属性和分类demo 多规格商品 子商品demo数据 --- beike/Admin/Services/FileManagerService.php | 2 + .../Controllers/DatabaseController.php | 4 +- beike/Repositories/AddressRepo.php | 3 +- beike/Repositories/CategoryRepo.php | 15 +- beike/Repositories/ProductRepo.php | 13 +- beike/Services/StateMachineService.php | 2 +- .../Http/Controllers/CategoryController.php | 2 +- beike/Shop/Http/Resources/ProductDetail.php | 2 +- database/seeders/AttributesSeeder.php | 340 ++++ database/seeders/ProductsSeeder.php | 1468 ++++++++++++----- 10 files changed, 1422 insertions(+), 429 deletions(-) create mode 100644 database/seeders/AttributesSeeder.php diff --git a/beike/Admin/Services/FileManagerService.php b/beike/Admin/Services/FileManagerService.php index 78540ebf..60549a7c 100644 --- a/beike/Admin/Services/FileManagerService.php +++ b/beike/Admin/Services/FileManagerService.php @@ -80,6 +80,7 @@ class FileManagerService $currentImages = $imageCollection->forPage($page, $perPage); $currentImages = $currentImages->map(function ($item) { $item['url'] = image_resize("{$item['path']}"); + return $item; }); @@ -210,6 +211,7 @@ class FileManagerService private function handleImage($filePath, $baseName): array { $path = "catalog{$filePath}"; + return [ 'path' => $path, 'name' => $baseName, diff --git a/beike/Installer/Controllers/DatabaseController.php b/beike/Installer/Controllers/DatabaseController.php index bd7a2c36..5c19af8f 100644 --- a/beike/Installer/Controllers/DatabaseController.php +++ b/beike/Installer/Controllers/DatabaseController.php @@ -32,9 +32,9 @@ class DatabaseController extends Controller public function index() { DB::statement('SET FOREIGN_KEY_CHECKS = 0'); - $rows = DB::select('SHOW TABLES'); + $rows = DB::select('SHOW TABLES'); $database = config('database.connections.mysql.database'); - $tables = array_column($rows, 'Tables_in_' . $database); + $tables = array_column($rows, 'Tables_in_' . $database); foreach ($tables as $table) { Schema::drop($table); } diff --git a/beike/Repositories/AddressRepo.php b/beike/Repositories/AddressRepo.php index acff7702..8caba6d9 100644 --- a/beike/Repositories/AddressRepo.php +++ b/beike/Repositories/AddressRepo.php @@ -80,7 +80,6 @@ class AddressRepo return $customer->addresses()->with('country')->get(); } - return collect(); - + return collect(); } } diff --git a/beike/Repositories/CategoryRepo.php b/beike/Repositories/CategoryRepo.php index 3c7ead05..e351e4c5 100644 --- a/beike/Repositories/CategoryRepo.php +++ b/beike/Repositories/CategoryRepo.php @@ -74,11 +74,12 @@ class CategoryRepo */ public static function getPerPages(): array { - $perPages = []; + $perPages = []; $configPerPage = system_setting('base.product_per_page', 20); for ($index = 1; $index <= 5; $index++) { $perPages[] = $configPerPage * $index; } + return $perPages; } @@ -165,9 +166,9 @@ class CategoryRepo $pathName .= $path->pathCategory->description->name; } $results[] = [ - 'id' => $category->id, + 'id' => $category->id, 'status' => $category->active, - 'name' => $pathName, + 'name' => $pathName, ]; } @@ -182,7 +183,7 @@ class CategoryRepo { if (is_int($category)) { $category = Category::query()->findOrFail($category); - } elseif (!($category instanceof Category)) { + } elseif (! ($category instanceof Category)) { throw new \Exception('invalid category'); } $category->descriptions()->delete(); @@ -198,7 +199,7 @@ class CategoryRepo */ public static function getName($category) { - $id = is_int($category) ? $category : $category->id; + $id = is_int($category) ? $category : $category->id; $categories = self::getAllCategoriesWithName(); return $categories[$id]['name'] ?? ''; @@ -214,11 +215,11 @@ class CategoryRepo return self::$allCategoryWithName; } - $items = []; + $items = []; $categories = self::getBuilder()->select('id')->get(); foreach ($categories as $category) { $items[$category->id] = [ - 'id' => $category->id, + 'id' => $category->id, 'name' => $category->description->name ?? '', ]; } diff --git a/beike/Repositories/ProductRepo.php b/beike/Repositories/ProductRepo.php index 23e82371..d3ad7d40 100644 --- a/beike/Repositories/ProductRepo.php +++ b/beike/Repositories/ProductRepo.php @@ -222,8 +222,9 @@ class ProductRepo } } - $results = array_map(function($item) { + $results = array_map(function ($item) { $item['values'] = array_values($item['values']); + return $item; }, $results); @@ -239,15 +240,15 @@ class ProductRepo $min = $builder->min('ps.price'); $max = $builder->max('ps.price'); - $priceArr = explode('-', $selectPrice); + $priceArr = explode('-', $selectPrice); $selectMin = $priceArr[0]; $selectMax = $priceArr[1]; return [ - 'min' => $min, - 'max' => $max, - 'select_min' => ($selectMin && $selectMin > $min) ? $selectMin : $min, - 'select_max' => ($selectMax && $selectMax < $max) ? $selectMax: $max, + 'min' => $min, + 'max' => $max, + 'select_min' => ($selectMin && $selectMin > $min) ? $selectMin : $min, + 'select_max' => ($selectMax && $selectMax < $max) ? $selectMax : $max, ]; } diff --git a/beike/Services/StateMachineService.php b/beike/Services/StateMachineService.php index e7e70dd6..dd411f9d 100644 --- a/beike/Services/StateMachineService.php +++ b/beike/Services/StateMachineService.php @@ -247,7 +247,7 @@ class StateMachineService private function updateSales() { $this->order->loadMissing([ - 'orderProducts' + 'orderProducts', ]); $orderProducts = $this->order->orderProducts; foreach ($orderProducts as $orderProduct) { diff --git a/beike/Shop/Http/Controllers/CategoryController.php b/beike/Shop/Http/Controllers/CategoryController.php index 2c46954b..b0adf6c7 100644 --- a/beike/Shop/Http/Controllers/CategoryController.php +++ b/beike/Shop/Http/Controllers/CategoryController.php @@ -23,7 +23,7 @@ class CategoryController extends Controller $filterData = array_merge($filterData, ['category_id' => $category->id, 'active' => 1]); $data = [ - 'all_categories' => CategoryRepo::getTwoLevelCategories(), + 'all_categories' => CategoryRepo::getTwoLevelCategories(), 'category' => $category, 'filter_data' => ['attr' => ProductRepo::getFilterAttribute($filterData), 'price' => ProductRepo::getFilterPrice($filterData)], 'products_format' => ProductSimple::collection($products)->jsonSerialize(), diff --git a/beike/Shop/Http/Resources/ProductDetail.php b/beike/Shop/Http/Resources/ProductDetail.php index 44914077..b6f57a05 100644 --- a/beike/Shop/Http/Resources/ProductDetail.php +++ b/beike/Shop/Http/Resources/ProductDetail.php @@ -22,7 +22,7 @@ class ProductDetail extends JsonResource { $attributes = []; foreach ($this->attributes as $ProductAttribute) { - if (!isset($attributes[$ProductAttribute->attribute->attribute_group_id]['attribute_group_name'])) { + if (! isset($attributes[$ProductAttribute->attribute->attribute_group_id]['attribute_group_name'])) { $attributes[$ProductAttribute->attribute->attribute_group_id]['attribute_group_name'] = $ProductAttribute->attribute->attributeGroup->description->name; } $attributes[$ProductAttribute->attribute->attribute_group_id]['attributes'][] = [ diff --git a/database/seeders/AttributesSeeder.php b/database/seeders/AttributesSeeder.php new file mode 100644 index 00000000..1834436f --- /dev/null +++ b/database/seeders/AttributesSeeder.php @@ -0,0 +1,340 @@ + + * @created 2023-01-12 19:20:05 + * @modified 2023-01-12 19:20:05 + */ + +namespace Database\Seeders; + +use Beike\Models\Attribute; +use Beike\Models\AttributeDescription; +use Beike\Models\AttributeGroup; +use Beike\Models\AttributeGroupDescription; +use Beike\Models\AttributeValue; +use Beike\Models\AttributeValueDescription; +use Beike\Models\ProductAttribute; +use Illuminate\Database\Seeder; + +class AttributesSeeder extends Seeder +{ + /** + * Run the database seeds. + * + * @return void + */ + public function run() + { + AttributeGroup::query()->truncate(); + AttributeGroupDescription::query()->truncate(); + Attribute::query()->truncate(); + AttributeDescription::query()->truncate(); + AttributeValue::query()->truncate(); + AttributeValueDescription::query()->truncate(); + ProductAttribute::query()->truncate(); + + // 属性组 + $attributeGroupsNumber = 4; + for ($i = 1; $i <= $attributeGroupsNumber; $i++) { + AttributeGroup::query()->create([ + 'sort_order' => $i + ]); + } + + // 属性组描述 + $items = $this->getGroupDescriptions(); + AttributeGroupDescription::query()->insert( + collect($items)->map(function ($item) { + $item['created_at'] = now(); + $item['updated_at'] = now(); + return $item; + })->toArray() + ); + + // 属性 + $items = $this->getAttributes(); + Attribute::query()->insert( + collect($items)->map(function ($item) { + $item['created_at'] = now(); + $item['updated_at'] = now(); + return $item; + })->toArray() + ); + + // 属性描述 + $items = $this->getAttributeDescriptions(); + AttributeDescription::query()->insert( + collect($items)->map(function ($item) { + $item['created_at'] = now(); + $item['updated_at'] = now(); + return $item; + })->toArray() + ); + + // 属性值 + $items = $this->getAttributeValues(); + AttributeValue::query()->insert( + collect($items)->map(function ($item) { + $item['created_at'] = now(); + $item['updated_at'] = now(); + return $item; + })->toArray() + ); + + // 属性值描述 + $items = $this->getAttributeValueDescriptions(); + AttributeValueDescription::query()->insert( + collect($items)->map(function ($item) { + $item['created_at'] = now(); + $item['updated_at'] = now(); + return $item; + })->toArray() + ); + + // 产品属性关联 + $items = $this->productAttributes(); + ProductAttribute::query()->insert( + collect($items)->map(function ($item) { + $item['created_at'] = now(); + $item['updated_at'] = now(); + return $item; + })->toArray() + ); + } + + + private function getGroupDescriptions(): array + { + return [ + ["attribute_group_id" => 1, "locale" => "zh_cn", "name" => "女装"], + ["attribute_group_id" => 1, "locale" => "en", "name" => "Women's clothing"], + ["attribute_group_id" => 2, "locale" => "zh_cn", "name" => "衣服"], + ["attribute_group_id" => 2, "locale" => "en", "name" => "Clothing"], + ["attribute_group_id" => 3, "locale" => "zh_cn", "name" => "运动户外"], + ["attribute_group_id" => 3, "locale" => "en", "name" => "Outdoor sport"], + ["attribute_group_id" => 4, "locale" => "zh_cn", "name" => "数码"], + ["attribute_group_id" => 4, "locale" => "en", "name" => "Digital"] + ]; + } + + + private function getAttributes(): array + { + return [ + ["attribute_group_id" => 2, "sort_order" => 0], + ["attribute_group_id" => 2, "sort_order" => 0], + ["attribute_group_id" => 2, "sort_order" => 0], + ["attribute_group_id" => 3, "sort_order" => 0], + ["attribute_group_id" => 4, "sort_order" => 0], + ["attribute_group_id" => 4, "sort_order" => 0] + ]; + } + + + private function getAttributeDescriptions(): array + { + return [ + ["attribute_id" => 1, "locale" => "zh_cn", "name" => "功能"], + ["attribute_id" => 1, "locale" => "en", "name" => "Features"], + ["attribute_id" => 2, "locale" => "zh_cn", "name" => "面料"], + ["attribute_id" => 2, "locale" => "en", "name" => "Fabric"], + ["attribute_id" => 3, "locale" => "zh_cn", "name" => "样式"], + ["attribute_id" => 3, "locale" => "en", "name" => "Style"], + ["attribute_id" => 4, "locale" => "zh_cn", "name" => "缓震"], + ["attribute_id" => 4, "locale" => "en", "name" => "Cushioning"], + ["attribute_id" => 5, "locale" => "zh_cn", "name" => "CUP"], + ["attribute_id" => 5, "locale" => "en", "name" => "CUP"], + ["attribute_id" => 6, "locale" => "zh_cn", "name" => "内存"], + ["attribute_id" => 6, "locale" => "en", "name" => "Memory"] + ]; + } + + + private function getAttributeValues(): array + { + return [ + ["attribute_id" => 2], + ["attribute_id" => 2], + ["attribute_id" => 1], + ["attribute_id" => 3], + ["attribute_id" => 2], + ["attribute_id" => 2], + ["attribute_id" => 2], + ["attribute_id" => 3], + ["attribute_id" => 3], + ["attribute_id" => 3], + ["attribute_id" => 1], + ["attribute_id" => 1], + ["attribute_id" => 4], + ["attribute_id" => 4], + ["attribute_id" => 4], + ["attribute_id" => 4], + ["attribute_id" => 4], + ["attribute_id" => 5], + ["attribute_id" => 5], + ["attribute_id" => 5], + ["attribute_id" => 5], + ["attribute_id" => 6], + ["attribute_id" => 6] + ]; + } + + + private function getAttributeValueDescriptions(): array + { + return [ + ["attribute_value_id" => 1, "locale" => "zh_cn", "name" => "棉"], + ["attribute_value_id" => 1, "locale" => "en", "name" => "Cotton"], + ["attribute_value_id" => 2, "locale" => "zh_cn", "name" => "麻"], + ["attribute_value_id" => 2, "locale" => "en", "name" => "Numb"], + ["attribute_value_id" => 5, "locale" => "en", "name" => "Silk"], + ["attribute_value_id" => 5, "locale" => "zh_cn", "name" => "丝"], + ["attribute_value_id" => 6, "locale" => "en", "name" => "Hair"], + ["attribute_value_id" => 6, "locale" => "zh_cn", "name" => "毛"], + ["attribute_value_id" => 7, "locale" => "zh_cn", "name" => "化纤"], + ["attribute_value_id" => 7, "locale" => "en", "name" => "Chemical fiber"], + ["attribute_value_id" => 4, "locale" => "zh_cn", "name" => "圆领"], + ["attribute_value_id" => 4, "locale" => "en", "name" => "Round neck"], + ["attribute_value_id" => 8, "locale" => "en", "name" => "Collarless"], + ["attribute_value_id" => 8, "locale" => "zh_cn", "name" => "无领"], + ["attribute_value_id" => 9, "locale" => "en", "name" => "Short sleeve"], + ["attribute_value_id" => 9, "locale" => "zh_cn", "name" => "短袖"], + ["attribute_value_id" => 10, "locale" => "zh_cn", "name" => "T恤"], + ["attribute_value_id" => 10, "locale" => "en", "name" => "T-shirt"], + ["attribute_value_id" => 3, "locale" => "zh_cn", "name" => "防水"], + ["attribute_value_id" => 3, "locale" => "en", "name" => "Water proof"], + ["attribute_value_id" => 11, "locale" => "zh_cn", "name" => "保暖"], + ["attribute_value_id" => 11, "locale" => "en", "name" => "keep warm"], + ["attribute_value_id" => 12, "locale" => "zh_cn", "name" => "防晒"], + ["attribute_value_id" => 12, "locale" => "en", "name" => "Sun protection"], + ["attribute_value_id" => 13, "locale" => "zh_cn", "name" => "Zoom气垫"], + ["attribute_value_id" => 13, "locale" => "en", "name" => "Zoom Air Cushion"], + ["attribute_value_id" => 14, "locale" => "zh_cn", "name" => "Max气垫"], + ["attribute_value_id" => 14, "locale" => "en", "name" => "Max Air Cushion"], + ["attribute_value_id" => 15, "locale" => "zh_cn", "name" => "Boost缓震材料"], + ["attribute_value_id" => 15, "locale" => "en", "name" => "Boost cushioning material"], + ["attribute_value_id" => 16, "locale" => "zh_cn", "name" => "Lightstrike科技"], + ["attribute_value_id" => 16, "locale" => "en", "name" => "Lightstrike Technology"], + ["attribute_value_id" => 17, "locale" => "en", "name" => "Fuel Cell Technology"], + ["attribute_value_id" => 17, "locale" => "zh_cn", "name" => "FuelCell科技"], + ["attribute_value_id" => 18, "locale" => "zh_cn", "name" => "i3"], + ["attribute_value_id" => 18, "locale" => "en", "name" => "i3"], + ["attribute_value_id" => 19, "locale" => "zh_cn", "name" => "i5"], + ["attribute_value_id" => 19, "locale" => "en", "name" => "i5"], + ["attribute_value_id" => 20, "locale" => "zh_cn", "name" => "i7"], + ["attribute_value_id" => 20, "locale" => "en", "name" => "i7"], + ["attribute_value_id" => 21, "locale" => "zh_cn", "name" => "i9"], + ["attribute_value_id" => 21, "locale" => "en", "name" => "i9"], + ["attribute_value_id" => 22, "locale" => "zh_cn", "name" => "DDR3"], + ["attribute_value_id" => 22, "locale" => "en", "name" => "DDR3"], + ["attribute_value_id" => 23, "locale" => "zh_cn", "name" => "DDR4"], + ["attribute_value_id" => 23, "locale" => "en", "name" => "DDR4"], + ]; + } + + + private function productAttributes(): array + { + return [ + ["product_id" => 5, "attribute_id" => 1, "attribute_value_id" => 11,], + ["product_id" => 5, "attribute_id" => 2, "attribute_value_id" => 5,], + ["product_id" => 5, "attribute_id" => 5, "attribute_value_id" => 20,], + ["product_id" => 5, "attribute_id" => 6, "attribute_value_id" => 23,], + ["product_id" => 5, "attribute_id" => 3, "attribute_value_id" => 10,], + ["product_id" => 6, "attribute_id" => 3, "attribute_value_id" => 8,], + ["product_id" => 6, "attribute_id" => 2, "attribute_value_id" => 1,], + ["product_id" => 6, "attribute_id" => 6, "attribute_value_id" => 23,], + ["product_id" => 6, "attribute_id" => 4, "attribute_value_id" => 14,], + ["product_id" => 7, "attribute_id" => 1, "attribute_value_id" => 11,], + ["product_id" => 7, "attribute_id" => 3, "attribute_value_id" => 10,], + ["product_id" => 7, "attribute_id" => 5, "attribute_value_id" => 21,], + ["product_id" => 7, "attribute_id" => 2, "attribute_value_id" => 5,], + ["product_id" => 7, "attribute_id" => 6, "attribute_value_id" => 23,], + ["product_id" => 8, "attribute_id" => 1, "attribute_value_id" => 12,], + ["product_id" => 8, "attribute_id" => 4, "attribute_value_id" => 14,], + ["product_id" => 8, "attribute_id" => 5, "attribute_value_id" => 21,], + ["product_id" => 8, "attribute_id" => 6, "attribute_value_id" => 22,], + ["product_id" => 8, "attribute_id" => 3, "attribute_value_id" => 9,], + ["product_id" => 8, "attribute_id" => 2, "attribute_value_id" => 5,], + ["product_id" => 9, "attribute_id" => 1, "attribute_value_id" => 3,], + ["product_id" => 9, "attribute_id" => 2, "attribute_value_id" => 1,], + ["product_id" => 9, "attribute_id" => 3, "attribute_value_id" => 8,], + ["product_id" => 9, "attribute_id" => 6, "attribute_value_id" => 22,], + ["product_id" => 9, "attribute_id" => 4, "attribute_value_id" => 16,], + ["product_id" => 9, "attribute_id" => 5, "attribute_value_id" => 19,], + ["product_id" => 10, "attribute_id" => 4, "attribute_value_id" => 17,], + ["product_id" => 10, "attribute_id" => 2, "attribute_value_id" => 5,], + ["product_id" => 10, "attribute_id" => 5, "attribute_value_id" => 20,], + ["product_id" => 10, "attribute_id" => 1, "attribute_value_id" => 3,], + ["product_id" => 10, "attribute_id" => 3, "attribute_value_id" => 9,], + ["product_id" => 11, "attribute_id" => 1, "attribute_value_id" => 3,], + ["product_id" => 11, "attribute_id" => 2, "attribute_value_id" => 1,], + ["product_id" => 11, "attribute_id" => 3, "attribute_value_id" => 4,], + ["product_id" => 11, "attribute_id" => 4, "attribute_value_id" => 14,], + ["product_id" => 11, "attribute_id" => 6, "attribute_value_id" => 23,], + ["product_id" => 12, "attribute_id" => 1, "attribute_value_id" => 3,], + ["product_id" => 12, "attribute_id" => 2, "attribute_value_id" => 5,], + ["product_id" => 12, "attribute_id" => 4, "attribute_value_id" => 13,], + ["product_id" => 12, "attribute_id" => 6, "attribute_value_id" => 23,], + ["product_id" => 12, "attribute_id" => 5, "attribute_value_id" => 20,], + ["product_id" => 12, "attribute_id" => 3, "attribute_value_id" => 9,], + ["product_id" => 13, "attribute_id" => 1, "attribute_value_id" => 11,], + ["product_id" => 13, "attribute_id" => 2, "attribute_value_id" => 1,], + ["product_id" => 13, "attribute_id" => 3, "attribute_value_id" => 9,], + ["product_id" => 13, "attribute_id" => 4, "attribute_value_id" => 14,], + ["product_id" => 13, "attribute_id" => 6, "attribute_value_id" => 23,], + ["product_id" => 13, "attribute_id" => 5, "attribute_value_id" => 19,], + ["product_id" => 14, "attribute_id" => 1, "attribute_value_id" => 3,], + ["product_id" => 14, "attribute_id" => 2, "attribute_value_id" => 2,], + ["product_id" => 14, "attribute_id" => 3, "attribute_value_id" => 8,], + ["product_id" => 14, "attribute_id" => 4, "attribute_value_id" => 14,], + ["product_id" => 14, "attribute_id" => 5, "attribute_value_id" => 20,], + ["product_id" => 14, "attribute_id" => 6, "attribute_value_id" => 23,], + ["product_id" => 15, "attribute_id" => 1, "attribute_value_id" => 3,], + ["product_id" => 15, "attribute_id" => 2, "attribute_value_id" => 1,], + ["product_id" => 15, "attribute_id" => 2, "attribute_value_id" => 6,], + ["product_id" => 15, "attribute_id" => 5, "attribute_value_id" => 20,], + ["product_id" => 15, "attribute_id" => 4, "attribute_value_id" => 16,], + ["product_id" => 15, "attribute_id" => 6, "attribute_value_id" => 22,], + ["product_id" => 35, "attribute_id" => 1, "attribute_value_id" => 3,], + ["product_id" => 35, "attribute_id" => 2, "attribute_value_id" => 6,], + ["product_id" => 35, "attribute_id" => 3, "attribute_value_id" => 8,], + ["product_id" => 35, "attribute_id" => 4, "attribute_value_id" => 15,], + ["product_id" => 35, "attribute_id" => 5, "attribute_value_id" => 21,], + ["product_id" => 35, "attribute_id" => 6, "attribute_value_id" => 22,], + ["product_id" => 39, "attribute_id" => 1, "attribute_value_id" => 11,], + ["product_id" => 39, "attribute_id" => 2, "attribute_value_id" => 2,], + ["product_id" => 39, "attribute_id" => 3, "attribute_value_id" => 9,], + ["product_id" => 39, "attribute_id" => 4, "attribute_value_id" => 15,], + ["product_id" => 39, "attribute_id" => 5, "attribute_value_id" => 19,], + ["product_id" => 39, "attribute_id" => 6, "attribute_value_id" => 23,], + ["product_id" => 1, "attribute_id" => 1, "attribute_value_id" => 3,], + ["product_id" => 1, "attribute_id" => 2, "attribute_value_id" => 1,], + ["product_id" => 1, "attribute_id" => 4, "attribute_value_id" => 15,], + ["product_id" => 1, "attribute_id" => 3, "attribute_value_id" => 10,], + ["product_id" => 1, "attribute_id" => 5, "attribute_value_id" => 21,], + ["product_id" => 1, "attribute_id" => 6, "attribute_value_id" => 22,], + ["product_id" => 2, "attribute_id" => 1, "attribute_value_id" => 3,], + ["product_id" => 2, "attribute_id" => 2, "attribute_value_id" => 1,], + ["product_id" => 2, "attribute_id" => 3, "attribute_value_id" => 4,], + ["product_id" => 2, "attribute_id" => 4, "attribute_value_id" => 13,], + ["product_id" => 2, "attribute_id" => 5, "attribute_value_id" => 18,], + ["product_id" => 2, "attribute_id" => 6, "attribute_value_id" => 22,], + ["product_id" => 3, "attribute_id" => 1, "attribute_value_id" => 12,], + ["product_id" => 3, "attribute_id" => 2, "attribute_value_id" => 5,], + ["product_id" => 3, "attribute_id" => 4, "attribute_value_id" => 14,], + ["product_id" => 3, "attribute_id" => 5, "attribute_value_id" => 20,], + ["product_id" => 3, "attribute_id" => 6, "attribute_value_id" => 23,], + ["product_id" => 4, "attribute_id" => 1, "attribute_value_id" => 11,], + ["product_id" => 4, "attribute_id" => 2, "attribute_value_id" => 7,], + ["product_id" => 4, "attribute_id" => 3, "attribute_value_id" => 10,], + ["product_id" => 4, "attribute_id" => 5, "attribute_value_id" => 21,], + ["product_id" => 4, "attribute_id" => 6, "attribute_value_id" => 23,] + ]; + } +} diff --git a/database/seeders/ProductsSeeder.php b/database/seeders/ProductsSeeder.php index e0b7255d..0c027494 100644 --- a/database/seeders/ProductsSeeder.php +++ b/database/seeders/ProductsSeeder.php @@ -12,6 +12,7 @@ namespace Database\Seeders; use Beike\Models\Product; +use Beike\Models\ProductRelation; use Beike\Models\ProductSku; use Illuminate\Database\Seeder; use Beike\Models\ProductCategory; @@ -26,6 +27,7 @@ class ProductsSeeder extends Seeder */ public function run() { + // 产品主表 $products = $this->getProducts(); if ($products) { Product::query()->truncate(); @@ -36,6 +38,7 @@ class ProductsSeeder extends Seeder } } + // 产品分类关联 $categories = $this->getProductCategories(); if ($categories) { ProductCategory::query()->truncate(); @@ -44,6 +47,7 @@ class ProductsSeeder extends Seeder } } + // 产品描述 $descriptions = $this->getProductDescriptions(); if ($descriptions) { ProductDescription::query()->truncate(); @@ -52,6 +56,7 @@ class ProductsSeeder extends Seeder } } + // 子商品SKU $skus = $this->getProductSkus(); if ($skus) { ProductSku::query()->truncate(); @@ -61,287 +66,570 @@ class ProductsSeeder extends Seeder ProductSku::query()->create($item); } } + + // 相关产品 + ProductRelation::query()->truncate(); + $items = $this->getProductRelations(); + ProductRelation::query()->insert( + collect($items)->map(function ($item) { + $item['created_at'] = now(); + $item['updated_at'] = now(); + return $item; + })->toArray() + ); } - public function getProducts() + private function getProducts(): array { return [ [ "id" => 1, "brand_id" => 10, - "video" => "", "images" => "[\"catalog/demo/product/1.jpg\", \"catalog/demo/product/2.jpg\", \"catalog/demo/product/4.jpg\"]", + "price" => 0, + "video" => "", "position" => 0, "active" => 1, "variables" => "[{\"name\": {\"en\": \"chima\", \"zh_cn\": \"尺码\"}, \"values\": [{\"name\": {\"en\": \"L\", \"zh_cn\": \"L\"}, \"image\": \"\"}, {\"name\": {\"en\": \"M\", \"zh_cn\": \"M\"}, \"image\": \"\"}], \"isImage\": false}, {\"name\": {\"en\": \"yanse\", \"zh_cn\": \"颜色\"}, \"values\": [{\"name\": {\"en\": \"黄色\", \"zh_cn\": \"黄色\"}, \"image\": \"\"}, {\"name\": {\"en\": \"绿色\", \"zh_cn\": \"绿色\"}, \"image\": \"\"}], \"isImage\": false}]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 2, "brand_id" => 11, - "video" => "", "images" => "[\"catalog/demo/product/13.jpg\", \"catalog/demo/product/10.jpg\", \"catalog/demo/product/11.jpg\", \"catalog/demo/product/12.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, - "variables" => "[]", - "tax_class_id" => 3, + "variables" => "[{\"name\": {\"en\": \"Size\", \"zh_cn\": \"尺寸\"}, \"values\": [{\"name\": {\"en\": \"S\", \"zh_cn\": \"S\"}, \"image\": \"\"}, {\"name\": {\"en\": \"M\", \"zh_cn\": \"M\"}, \"image\": \"\"}, {\"name\": {\"en\": \"L\", \"zh_cn\": \"L\"}, \"image\": \"\"}], \"isImage\": false}, {\"name\": {\"en\": \"颜色\", \"zh_cn\": \"颜色\"}, \"values\": [{\"name\": {\"en\": \"Yellow\", \"zh_cn\": \"黄色\"}, \"image\": \"\"}, {\"name\": {\"en\": \"Blue\", \"zh_cn\": \"蓝色\"}, \"image\": \"\"}], \"isImage\": false}]", + "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 3, "brand_id" => 4, + "images" => "[\"catalog/demo/product/12.jpg\", \"catalog/demo/product/13.jpg\", \"catalog/demo/product/17.jpg\"]", + "price" => 0, "video" => "", - "images" => "[\"catalog/demo/product/17.jpg\", \"catalog/demo/product/11.jpg\", \"catalog/demo/product/12.jpg\", \"catalog/demo/product/13.jpg\"]", "position" => 1, "active" => 1, - "variables" => "[]", + "variables" => "[{\"name\": {\"en\": \"Size\", \"zh_cn\": \"尺码\"}, \"values\": [{\"name\": {\"en\": \"S\", \"zh_cn\": \"S\"}, \"image\": \"\"}, {\"name\": {\"en\": \"M\", \"zh_cn\": \"M\"}, \"image\": \"\"}, {\"name\": {\"en\": \"L\", \"zh_cn\": \"L\"}, \"image\": \"\"}, {\"name\": {\"en\": \"XL\", \"zh_cn\": \"XL\"}, \"image\": \"\"}], \"isImage\": false}, {\"name\": {\"en\": \"Color\", \"zh_cn\": \"颜色\"}, \"values\": [{\"name\": {\"en\": \"Green\", \"zh_cn\": \"绿色\"}, \"image\": \"\"}, {\"name\": {\"en\": \"White\", \"zh_cn\": \"白色\"}, \"image\": \"\"}], \"isImage\": false}]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 4, "brand_id" => 7, - "video" => "", "images" => "[\"catalog/demo/product/3.jpg\", \"catalog/demo/product/16.jpg\", \"catalog/demo/product/15.jpg\", \"catalog/demo/product/12.jpg\", \"catalog/demo/product/13.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, - "variables" => "[]", + "variables" => "[{\"name\": {\"en\": \"Size\", \"zh_cn\": \"尺码\"}, \"values\": [{\"name\": {\"en\": \"S\", \"zh_cn\": \"S\"}, \"image\": \"\"}, {\"name\": {\"en\": \"M\", \"zh_cn\": \"M\"}, \"image\": \"\"}, {\"name\": {\"en\": \"L\", \"zh_cn\": \"L\"}, \"image\": \"\"}, {\"name\": {\"en\": \"XL\", \"zh_cn\": \"XL\"}, \"image\": \"\"}], \"isImage\": false}, {\"name\": {\"en\": \"Color\", \"zh_cn\": \"颜色\"}, \"values\": [{\"name\": {\"en\": \"White\", \"zh_cn\": \"白色\"}, \"image\": \"\"}, {\"name\": {\"en\": \"Green\", \"zh_cn\": \"绿色\"}, \"image\": \"\"}], \"isImage\": false}]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 5, "brand_id" => 3, - "video" => "", "images" => "[\"catalog/demo/product/4.jpg\", \"catalog/demo/product/15.jpg\", \"catalog/demo/product/16.jpg\", \"catalog/demo/product/17.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, "variables" => "[]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 6, "brand_id" => 2, - "video" => "", "images" => "[\"catalog/demo/product/7.jpg\", \"catalog/demo/product/11.jpg\", \"catalog/demo/product/12.jpg\", \"catalog/demo/product/13.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, - "active" => 0, + "active" => 1, "variables" => "[]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 7, "brand_id" => 8, - "video" => "", "images" => "[\"catalog/demo/product/5.jpg\", \"catalog/demo/product/16.jpg\", \"catalog/demo/product/3.jpg\", \"catalog/demo/product/9.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, "variables" => "[]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 8, "brand_id" => 5, - "video" => "", "images" => "[\"catalog/demo/product/12.jpg\", \"catalog/demo/product/10.jpg\", \"catalog/demo/product/11.jpg\", \"catalog/demo/product/13.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, "variables" => "[]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 9, "brand_id" => 2, - "video" => "", "images" => "[\"catalog/demo/product/14.jpg\", \"catalog/demo/product/10.jpg\", \"catalog/demo/product/11.jpg\", \"catalog/demo/product/12.jpg\", \"catalog/demo/product/13.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, "variables" => "[]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 10, "brand_id" => 1, - "video" => "", "images" => "[\"catalog/demo/product/9.jpg\", \"catalog/demo/product/10.jpg\", \"catalog/demo/product/11.jpg\", \"catalog/demo/product/12.jpg\", \"catalog/demo/product/13.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, "variables" => "[]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 11, "brand_id" => 2, - "video" => "", "images" => "[\"catalog/demo/product/10.jpg\", \"catalog/demo/product/11.jpg\", \"catalog/demo/product/12.jpg\", \"catalog/demo/product/13.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, "variables" => "[]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 12, "brand_id" => 2, - "video" => "", "images" => "[\"catalog/demo/product/16.jpg\", \"catalog/demo/product/10.jpg\", \"catalog/demo/product/11.jpg\", \"catalog/demo/product/12.jpg\", \"catalog/demo/product/13.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, "variables" => "[]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 13, "brand_id" => 8, - "video" => "", "images" => "[\"catalog/demo/product/2.jpg\", \"catalog/demo/product/3.jpg\", \"catalog/demo/product/4.jpg\", \"catalog/demo/product/5.jpg\", \"catalog/demo/product/6.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, "variables" => "[]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 14, "brand_id" => 9, - "video" => "", "images" => "[\"catalog/demo/product/6.jpg\", \"catalog/demo/product/10.jpg\", \"catalog/demo/product/11.jpg\", \"catalog/demo/product/12.jpg\", \"catalog/demo/product/13.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, "variables" => "[]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 15, "brand_id" => 6, - "video" => "", "images" => "[\"catalog/demo/product/15.jpg\", \"catalog/demo/product/10.jpg\", \"catalog/demo/product/11.jpg\", \"catalog/demo/product/12.jpg\", \"catalog/demo/product/13.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, "variables" => "[]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 35, "brand_id" => 1, - "video" => "", "images" => "[\"catalog/demo/product/18.jpg\", \"catalog/demo/product/2.jpg\", \"catalog/demo/product/3.jpg\", \"catalog/demo/product/4.jpg\", \"catalog/demo/product/5.jpg\", \"catalog/demo/product/6.jpg\", \"catalog/demo/product/7.jpg\", \"catalog/demo/product/9.jpg\", \"catalog/demo/product/xq_01.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, "variables" => "[]", - "tax_class_id" => 2, + "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ], [ "id" => 39, "brand_id" => 4, - "video" => "", "images" => "[\"catalog/demo/product/11.jpg\", \"catalog/demo/product/12.jpg\", \"catalog/demo/product/13.jpg\", \"catalog/demo/product/14.jpg\", \"catalog/demo/product/15.jpg\", \"catalog/demo/product/16.jpg\", \"catalog/demo/product/17.jpg\", \"catalog/demo/product/18.jpg\", \"catalog/demo/product/2.jpg\"]", + "price" => 0, + "video" => "", "position" => 1, "active" => 1, "variables" => "[{\"name\": {\"en\": \"color\", \"zh_cn\": \"颜色\"}, \"values\": [{\"name\": {\"en\": \"yellow\", \"zh_cn\": \"黄色\"}, \"image\": \"\"}, {\"name\": {\"en\": \"green\", \"zh_cn\": \"绿色\"}, \"image\": \"\"}], \"isImage\": true}, {\"name\": {\"en\": \"规格\", \"zh_cn\": \"规格\"}, \"values\": [{\"name\": {\"en\": \"450ML\", \"zh_cn\": \"450ML\"}, \"image\": \"\"}, {\"name\": {\"en\": \"500ml\", \"zh_cn\": \"500ml\"}, \"image\": \"\"}], \"isImage\": false}]", "tax_class_id" => 1, + "sales" => 0, + "deleted_at" => null ] ]; } - public function getProductCategories() + private function getProductCategories(): array { return [ - ["id" => 1, "product_id" => 2, "category_id" => 100000], - ["id" => 3, "product_id" => 2, "category_id" => 100002], - ["id" => 4, "product_id" => 2, "category_id" => 100003], - ["id" => 5, "product_id" => 2, "category_id" => 100004], - ["id" => 6, "product_id" => 2, "category_id" => 100005], - ["id" => 7, "product_id" => 2, "category_id" => 100008], - ["id" => 8, "product_id" => 2, "category_id" => 100007], - ["id" => 9, "product_id" => 2, "category_id" => 100009], - ["id" => 10, "product_id" => 14, "category_id" => 100000], - ["id" => 12, "product_id" => 14, "category_id" => 100002], - ["id" => 13, "product_id" => 14, "category_id" => 100003], - ["id" => 14, "product_id" => 14, "category_id" => 100004], - ["id" => 15, "product_id" => 14, "category_id" => 100005], - ["id" => 16, "product_id" => 14, "category_id" => 100008], - ["id" => 17, "product_id" => 14, "category_id" => 100007], - ["id" => 18, "product_id" => 14, "category_id" => 100009], - ["id" => 19, "product_id" => 15, "category_id" => 100000], - ["id" => 21, "product_id" => 15, "category_id" => 100002], - ["id" => 22, "product_id" => 15, "category_id" => 100003], - ["id" => 23, "product_id" => 15, "category_id" => 100004], - ["id" => 24, "product_id" => 15, "category_id" => 100005], - ["id" => 25, "product_id" => 15, "category_id" => 100008], - ["id" => 26, "product_id" => 15, "category_id" => 100007], - ["id" => 27, "product_id" => 15, "category_id" => 100009], - ["id" => 28, "product_id" => 16, "category_id" => 100000], - ["id" => 30, "product_id" => 16, "category_id" => 100002], - ["id" => 31, "product_id" => 16, "category_id" => 100003], - ["id" => 32, "product_id" => 16, "category_id" => 100004], - ["id" => 33, "product_id" => 16, "category_id" => 100005], - ["id" => 34, "product_id" => 16, "category_id" => 100008], - ["id" => 35, "product_id" => 16, "category_id" => 100007], - ["id" => 36, "product_id" => 16, "category_id" => 100009], - ["id" => 37, "product_id" => 17, "category_id" => 100000], - ["id" => 39, "product_id" => 17, "category_id" => 100002], - ["id" => 40, "product_id" => 17, "category_id" => 100003], - ["id" => 41, "product_id" => 17, "category_id" => 100004], - ["id" => 42, "product_id" => 17, "category_id" => 100005], - ["id" => 43, "product_id" => 17, "category_id" => 100008], - ["id" => 44, "product_id" => 17, "category_id" => 100007], - ["id" => 45, "product_id" => 17, "category_id" => 100009], - ["id" => 46, "product_id" => 18, "category_id" => 100000], - ["id" => 48, "product_id" => 18, "category_id" => 100002], - ["id" => 49, "product_id" => 18, "category_id" => 100003], - ["id" => 50, "product_id" => 18, "category_id" => 100004], - ["id" => 51, "product_id" => 18, "category_id" => 100005], - ["id" => 52, "product_id" => 18, "category_id" => 100008], - ["id" => 53, "product_id" => 18, "category_id" => 100007], - ["id" => 54, "product_id" => 18, "category_id" => 100009], - ["id" => 55, "product_id" => 19, "category_id" => 100000], - ["id" => 57, "product_id" => 19, "category_id" => 100002], - ["id" => 58, "product_id" => 19, "category_id" => 100003], - ["id" => 59, "product_id" => 19, "category_id" => 100004], - ["id" => 60, "product_id" => 19, "category_id" => 100005], - ["id" => 61, "product_id" => 19, "category_id" => 100008], - ["id" => 62, "product_id" => 19, "category_id" => 100007], - ["id" => 63, "product_id" => 19, "category_id" => 100009], - ["id" => 64, "product_id" => 20, "category_id" => 100000], - ["id" => 66, "product_id" => 20, "category_id" => 100002], - ["id" => 67, "product_id" => 20, "category_id" => 100003], - ["id" => 68, "product_id" => 20, "category_id" => 100004], - ["id" => 69, "product_id" => 20, "category_id" => 100005], - ["id" => 70, "product_id" => 20, "category_id" => 100008], - ["id" => 71, "product_id" => 20, "category_id" => 100007], - ["id" => 72, "product_id" => 20, "category_id" => 100009], - ["id" => 76, "product_id" => 1, "category_id" => 100015], - ["id" => 79, "product_id" => 2, "category_id" => 100013], - ["id" => 81, "product_id" => 2, "category_id" => 100010], - ["id" => 82, "product_id" => 2, "category_id" => 100011], - ["id" => 85, "product_id" => 2, "category_id" => 100012], - ["id" => 86, "product_id" => 2, "category_id" => 100014], - ["id" => 87, "product_id" => 2, "category_id" => 100015], - ["id" => 88, "product_id" => 2, "category_id" => 100019], - ["id" => 89, "product_id" => 2, "category_id" => 100018], - ["id" => 90, "product_id" => 2, "category_id" => 100020], - ["id" => 104, "product_id" => 31, "category_id" => 100011], - ["id" => 105, "product_id" => 32, "category_id" => 100008], - ["id" => 106, "product_id" => 32, "category_id" => 100011], - ["id" => 107, "product_id" => 32, "category_id" => 100012], - ["id" => 108, "product_id" => 32, "category_id" => 100014], - ["id" => 109, "product_id" => 34, "category_id" => 100013], - ["id" => 110, "product_id" => 35, "category_id" => 100011], - ["id" => 111, "product_id" => 35, "category_id" => 100012], - ["id" => 112, "product_id" => 39, "category_id" => 100013], - ["id" => 113, "product_id" => 39, "category_id" => 100000], - ["id" => 116, "product_id" => 39, "category_id" => 100002], - ["id" => 117, "product_id" => 39, "category_id" => 100010], - ["id" => 118, "product_id" => 39, "category_id" => 100003], - ["id" => 119, "product_id" => 39, "category_id" => 100004], - ["id" => 120, "product_id" => 39, "category_id" => 100005], - ["id" => 121, "product_id" => 39, "category_id" => 100008], - ["id" => 122, "product_id" => 39, "category_id" => 100011], - ["id" => 123, "product_id" => 39, "category_id" => 100012], - ["id" => 124, "product_id" => 39, "category_id" => 100014], - ["id" => 125, "product_id" => 39, "category_id" => 100015], - ["id" => 126, "product_id" => 39, "category_id" => 100019], + ["product_id" => 2, "category_id" => 100002,], + ["product_id" => 2, "category_id" => 100003,], + ["product_id" => 2, "category_id" => 100004,], + ["product_id" => 2, "category_id" => 100005,], + ["product_id" => 2, "category_id" => 100008,], + ["product_id" => 2, "category_id" => 100007,], + ["product_id" => 14, "category_id" => 100002,], + ["product_id" => 14, "category_id" => 100003,], + ["product_id" => 14, "category_id" => 100004,], + ["product_id" => 14, "category_id" => 100005,], + ["product_id" => 14, "category_id" => 100008,], + ["product_id" => 14, "category_id" => 100007,], + ["product_id" => 15, "category_id" => 100002,], + ["product_id" => 15, "category_id" => 100003,], + ["product_id" => 15, "category_id" => 100004,], + ["product_id" => 15, "category_id" => 100005,], + ["product_id" => 15, "category_id" => 100008,], + ["product_id" => 15, "category_id" => 100007,], + ["product_id" => 16, "category_id" => 100000,], + ["product_id" => 16, "category_id" => 100002,], + ["product_id" => 16, "category_id" => 100003,], + ["product_id" => 16, "category_id" => 100004,], + ["product_id" => 16, "category_id" => 100005,], + ["product_id" => 16, "category_id" => 100008,], + ["product_id" => 16, "category_id" => 100007,], + ["product_id" => 16, "category_id" => 100009,], + ["product_id" => 17, "category_id" => 100000,], + ["product_id" => 17, "category_id" => 100002,], + ["product_id" => 17, "category_id" => 100003,], + ["product_id" => 17, "category_id" => 100004,], + ["product_id" => 17, "category_id" => 100005,], + ["product_id" => 17, "category_id" => 100008,], + ["product_id" => 17, "category_id" => 100007,], + ["product_id" => 17, "category_id" => 100009,], + ["product_id" => 18, "category_id" => 100000,], + ["product_id" => 18, "category_id" => 100002,], + ["product_id" => 18, "category_id" => 100003,], + ["product_id" => 18, "category_id" => 100004,], + ["product_id" => 18, "category_id" => 100005,], + ["product_id" => 18, "category_id" => 100008,], + ["product_id" => 18, "category_id" => 100007,], + ["product_id" => 18, "category_id" => 100009,], + ["product_id" => 19, "category_id" => 100000,], + ["product_id" => 19, "category_id" => 100002,], + ["product_id" => 19, "category_id" => 100003,], + ["product_id" => 19, "category_id" => 100004,], + ["product_id" => 19, "category_id" => 100005,], + ["product_id" => 19, "category_id" => 100008,], + ["product_id" => 19, "category_id" => 100007,], + ["product_id" => 19, "category_id" => 100009,], + ["product_id" => 20, "category_id" => 100000,], + ["product_id" => 20, "category_id" => 100002,], + ["product_id" => 20, "category_id" => 100003,], + ["product_id" => 20, "category_id" => 100004,], + ["product_id" => 20, "category_id" => 100005,], + ["product_id" => 20, "category_id" => 100008,], + ["product_id" => 20, "category_id" => 100007,], + ["product_id" => 20, "category_id" => 100009,], + ["product_id" => 1, "category_id" => 100015,], + ["product_id" => 2, "category_id" => 100013,], + ["product_id" => 2, "category_id" => 100010,], + ["product_id" => 2, "category_id" => 100011,], + ["product_id" => 2, "category_id" => 100012,], + ["product_id" => 2, "category_id" => 100014,], + ["product_id" => 2, "category_id" => 100015,], + ["product_id" => 2, "category_id" => 100018,], + ["product_id" => 31, "category_id" => 100011,], + ["product_id" => 32, "category_id" => 100008,], + ["product_id" => 32, "category_id" => 100011,], + ["product_id" => 32, "category_id" => 100012,], + ["product_id" => 32, "category_id" => 100014,], + ["product_id" => 34, "category_id" => 100013,], + ["product_id" => 35, "category_id" => 100011,], + ["product_id" => 35, "category_id" => 100012,], + ["product_id" => 39, "category_id" => 100013,], + ["product_id" => 39, "category_id" => 100002,], + ["product_id" => 39, "category_id" => 100010,], + ["product_id" => 39, "category_id" => 100003,], + ["product_id" => 39, "category_id" => 100004,], + ["product_id" => 39, "category_id" => 100005,], + ["product_id" => 39, "category_id" => 100008,], + ["product_id" => 39, "category_id" => 100011,], + ["product_id" => 39, "category_id" => 100012,], + ["product_id" => 39, "category_id" => 100014,], + ["product_id" => 39, "category_id" => 100015,], + ["product_id" => 2, "category_id" => 100016,], + ["product_id" => 2, "category_id" => 100006,], + ["product_id" => 3, "category_id" => 100012,], + ["product_id" => 3, "category_id" => 100018,], + ["product_id" => 3, "category_id" => 100017,], + ["product_id" => 3, "category_id" => 100003,], + ["product_id" => 3, "category_id" => 100005,], + ["product_id" => 3, "category_id" => 100007,], + ["product_id" => 3, "category_id" => 100002,], + ["product_id" => 3, "category_id" => 100004,], + ["product_id" => 3, "category_id" => 100010,], + ["product_id" => 3, "category_id" => 100013,], + ["product_id" => 3, "category_id" => 100015,], + ["product_id" => 3, "category_id" => 100014,], + ["product_id" => 3, "category_id" => 100016,], + ["product_id" => 3, "category_id" => 100011,], + ["product_id" => 3, "category_id" => 100006,], + ["product_id" => 3, "category_id" => 100008,], + ["product_id" => 4, "category_id" => 100012,], + ["product_id" => 4, "category_id" => 100018,], + ["product_id" => 4, "category_id" => 100017,], + ["product_id" => 4, "category_id" => 100003,], + ["product_id" => 4, "category_id" => 100005,], + ["product_id" => 4, "category_id" => 100007,], + ["product_id" => 4, "category_id" => 100002,], + ["product_id" => 4, "category_id" => 100004,], + ["product_id" => 4, "category_id" => 100010,], + ["product_id" => 4, "category_id" => 100013,], + ["product_id" => 4, "category_id" => 100015,], + ["product_id" => 4, "category_id" => 100014,], + ["product_id" => 4, "category_id" => 100016,], + ["product_id" => 4, "category_id" => 100011,], + ["product_id" => 4, "category_id" => 100006,], + ["product_id" => 4, "category_id" => 100008,], + ["product_id" => 6, "category_id" => 100012,], + ["product_id" => 6, "category_id" => 100018,], + ["product_id" => 6, "category_id" => 100017,], + ["product_id" => 6, "category_id" => 100003,], + ["product_id" => 6, "category_id" => 100005,], + ["product_id" => 6, "category_id" => 100007,], + ["product_id" => 6, "category_id" => 100002,], + ["product_id" => 6, "category_id" => 100004,], + ["product_id" => 6, "category_id" => 100010,], + ["product_id" => 6, "category_id" => 100013,], + ["product_id" => 6, "category_id" => 100015,], + ["product_id" => 6, "category_id" => 100014,], + ["product_id" => 6, "category_id" => 100016,], + ["product_id" => 6, "category_id" => 100011,], + ["product_id" => 6, "category_id" => 100006,], + ["product_id" => 1, "category_id" => 100012,], + ["product_id" => 1, "category_id" => 100018,], + ["product_id" => 1, "category_id" => 100017,], + ["product_id" => 1, "category_id" => 100003,], + ["product_id" => 1, "category_id" => 100005,], + ["product_id" => 1, "category_id" => 100007,], + ["product_id" => 1, "category_id" => 100002,], + ["product_id" => 1, "category_id" => 100004,], + ["product_id" => 1, "category_id" => 100010,], + ["product_id" => 1, "category_id" => 100013,], + ["product_id" => 1, "category_id" => 100014,], + ["product_id" => 1, "category_id" => 100016,], + ["product_id" => 1, "category_id" => 100011,], + ["product_id" => 1, "category_id" => 100006,], + ["product_id" => 1, "category_id" => 100008,], + ["product_id" => 39, "category_id" => 100018,], + ["product_id" => 39, "category_id" => 100017,], + ["product_id" => 39, "category_id" => 100007,], + ["product_id" => 39, "category_id" => 100016,], + ["product_id" => 35, "category_id" => 100018,], + ["product_id" => 35, "category_id" => 100017,], + ["product_id" => 35, "category_id" => 100003,], + ["product_id" => 35, "category_id" => 100005,], + ["product_id" => 35, "category_id" => 100007,], + ["product_id" => 35, "category_id" => 100002,], + ["product_id" => 35, "category_id" => 100004,], + ["product_id" => 35, "category_id" => 100010,], + ["product_id" => 35, "category_id" => 100013,], + ["product_id" => 35, "category_id" => 100015,], + ["product_id" => 35, "category_id" => 100014,], + ["product_id" => 35, "category_id" => 100016,], + ["product_id" => 35, "category_id" => 100006,], + ["product_id" => 35, "category_id" => 100008,], + ["product_id" => 15, "category_id" => 100012,], + ["product_id" => 15, "category_id" => 100018,], + ["product_id" => 15, "category_id" => 100017,], + ["product_id" => 15, "category_id" => 100010,], + ["product_id" => 15, "category_id" => 100013,], + ["product_id" => 15, "category_id" => 100015,], + ["product_id" => 15, "category_id" => 100014,], + ["product_id" => 15, "category_id" => 100016,], + ["product_id" => 15, "category_id" => 100011,], + ["product_id" => 15, "category_id" => 100006,], + ["product_id" => 14, "category_id" => 100012,], + ["product_id" => 14, "category_id" => 100018,], + ["product_id" => 14, "category_id" => 100017,], + ["product_id" => 14, "category_id" => 100010,], + ["product_id" => 14, "category_id" => 100013,], + ["product_id" => 14, "category_id" => 100015,], + ["product_id" => 14, "category_id" => 100014,], + ["product_id" => 14, "category_id" => 100016,], + ["product_id" => 14, "category_id" => 100011,], + ["product_id" => 14, "category_id" => 100006,], + ["product_id" => 13, "category_id" => 100012,], + ["product_id" => 13, "category_id" => 100018,], + ["product_id" => 13, "category_id" => 100017,], + ["product_id" => 13, "category_id" => 100003,], + ["product_id" => 13, "category_id" => 100005,], + ["product_id" => 13, "category_id" => 100007,], + ["product_id" => 13, "category_id" => 100002,], + ["product_id" => 13, "category_id" => 100004,], + ["product_id" => 13, "category_id" => 100010,], + ["product_id" => 13, "category_id" => 100013,], + ["product_id" => 13, "category_id" => 100015,], + ["product_id" => 13, "category_id" => 100014,], + ["product_id" => 13, "category_id" => 100016,], + ["product_id" => 13, "category_id" => 100011,], + ["product_id" => 13, "category_id" => 100006,], + ["product_id" => 13, "category_id" => 100008,], + ["product_id" => 12, "category_id" => 100012,], + ["product_id" => 12, "category_id" => 100018,], + ["product_id" => 12, "category_id" => 100017,], + ["product_id" => 12, "category_id" => 100003,], + ["product_id" => 12, "category_id" => 100005,], + ["product_id" => 12, "category_id" => 100007,], + ["product_id" => 12, "category_id" => 100002,], + ["product_id" => 12, "category_id" => 100004,], + ["product_id" => 12, "category_id" => 100010,], + ["product_id" => 12, "category_id" => 100013,], + ["product_id" => 12, "category_id" => 100015,], + ["product_id" => 12, "category_id" => 100014,], + ["product_id" => 12, "category_id" => 100016,], + ["product_id" => 12, "category_id" => 100011,], + ["product_id" => 12, "category_id" => 100006,], + ["product_id" => 12, "category_id" => 100008,], + ["product_id" => 11, "category_id" => 100012,], + ["product_id" => 11, "category_id" => 100018,], + ["product_id" => 11, "category_id" => 100017,], + ["product_id" => 11, "category_id" => 100003,], + ["product_id" => 11, "category_id" => 100005,], + ["product_id" => 11, "category_id" => 100007,], + ["product_id" => 11, "category_id" => 100002,], + ["product_id" => 11, "category_id" => 100004,], + ["product_id" => 11, "category_id" => 100010,], + ["product_id" => 11, "category_id" => 100013,], + ["product_id" => 11, "category_id" => 100015,], + ["product_id" => 11, "category_id" => 100014,], + ["product_id" => 11, "category_id" => 100016,], + ["product_id" => 11, "category_id" => 100011,], + ["product_id" => 11, "category_id" => 100006,], + ["product_id" => 11, "category_id" => 100008,], + ["product_id" => 10, "category_id" => 100012,], + ["product_id" => 10, "category_id" => 100018,], + ["product_id" => 10, "category_id" => 100017,], + ["product_id" => 10, "category_id" => 100003,], + ["product_id" => 10, "category_id" => 100005,], + ["product_id" => 10, "category_id" => 100007,], + ["product_id" => 10, "category_id" => 100002,], + ["product_id" => 10, "category_id" => 100004,], + ["product_id" => 10, "category_id" => 100010,], + ["product_id" => 10, "category_id" => 100013,], + ["product_id" => 10, "category_id" => 100015,], + ["product_id" => 10, "category_id" => 100014,], + ["product_id" => 10, "category_id" => 100016,], + ["product_id" => 10, "category_id" => 100011,], + ["product_id" => 10, "category_id" => 100006,], + ["product_id" => 10, "category_id" => 100008,], + ["product_id" => 9, "category_id" => 100012,], + ["product_id" => 9, "category_id" => 100018,], + ["product_id" => 9, "category_id" => 100017,], + ["product_id" => 9, "category_id" => 100003,], + ["product_id" => 9, "category_id" => 100005,], + ["product_id" => 9, "category_id" => 100007,], + ["product_id" => 9, "category_id" => 100002,], + ["product_id" => 9, "category_id" => 100004,], + ["product_id" => 9, "category_id" => 100010,], + ["product_id" => 9, "category_id" => 100013,], + ["product_id" => 9, "category_id" => 100015,], + ["product_id" => 9, "category_id" => 100014,], + ["product_id" => 9, "category_id" => 100016,], + ["product_id" => 9, "category_id" => 100011,], + ["product_id" => 9, "category_id" => 100006,], + ["product_id" => 9, "category_id" => 100008,], + ["product_id" => 8, "category_id" => 100012,], + ["product_id" => 8, "category_id" => 100018,], + ["product_id" => 8, "category_id" => 100017,], + ["product_id" => 8, "category_id" => 100003,], + ["product_id" => 8, "category_id" => 100005,], + ["product_id" => 8, "category_id" => 100007,], + ["product_id" => 8, "category_id" => 100002,], + ["product_id" => 8, "category_id" => 100004,], + ["product_id" => 8, "category_id" => 100010,], + ["product_id" => 8, "category_id" => 100013,], + ["product_id" => 8, "category_id" => 100015,], + ["product_id" => 8, "category_id" => 100014,], + ["product_id" => 8, "category_id" => 100016,], + ["product_id" => 8, "category_id" => 100011,], + ["product_id" => 8, "category_id" => 100006,], + ["product_id" => 8, "category_id" => 100008,], + ["product_id" => 7, "category_id" => 100012,], + ["product_id" => 7, "category_id" => 100018,], + ["product_id" => 7, "category_id" => 100017,], + ["product_id" => 7, "category_id" => 100003,], + ["product_id" => 7, "category_id" => 100005,], + ["product_id" => 7, "category_id" => 100007,], + ["product_id" => 7, "category_id" => 100002,], + ["product_id" => 7, "category_id" => 100004,], + ["product_id" => 7, "category_id" => 100010,], + ["product_id" => 7, "category_id" => 100013,], + ["product_id" => 7, "category_id" => 100015,], + ["product_id" => 7, "category_id" => 100014,], + ["product_id" => 7, "category_id" => 100016,], + ["product_id" => 7, "category_id" => 100011,], + ["product_id" => 7, "category_id" => 100006,], + ["product_id" => 7, "category_id" => 100008,], + ["product_id" => 6, "category_id" => 100008,], + ["product_id" => 5, "category_id" => 100012,], + ["product_id" => 5, "category_id" => 100018,], + ["product_id" => 5, "category_id" => 100017,], + ["product_id" => 5, "category_id" => 100003,], + ["product_id" => 5, "category_id" => 100005,], + ["product_id" => 5, "category_id" => 100007,], + ["product_id" => 5, "category_id" => 100002,], + ["product_id" => 5, "category_id" => 100004,], + ["product_id" => 5, "category_id" => 100010,], + ["product_id" => 5, "category_id" => 100013,], + ["product_id" => 5, "category_id" => 100015,], + ["product_id" => 5, "category_id" => 100014,], + ["product_id" => 5, "category_id" => 100016,], + ["product_id" => 5, "category_id" => 100011,], + ["product_id" => 5, "category_id" => 100006,], + ["product_id" => 5, "category_id" => 100008,], ]; } - public function getProductDescriptions() + private function getProductDescriptions(): array { return [ [ @@ -889,7 +1177,7 @@ class ProductsSeeder extends Seeder ]; } - public function getProductSkus() + private function getProductSkus(): array { return [ [ @@ -897,6 +1185,7 @@ class ProductsSeeder extends Seeder "product_id" => 16, "variants" => "\"\"", "position" => 0, + "images" => null, "model" => "23", "sku" => "231", "price" => 324, @@ -904,13 +1193,13 @@ class ProductsSeeder extends Seeder "cost_price" => 43, "quantity" => 546, "is_default" => 1, - "images" => null ], [ "id" => 15, "product_id" => 17, "variants" => "\"\"", "position" => 0, + "images" => null, "model" => "23", "sku" => "231", "price" => 324, @@ -918,13 +1207,13 @@ class ProductsSeeder extends Seeder "cost_price" => 43, "quantity" => 546, "is_default" => 1, - "images" => null ], [ "id" => 16, "product_id" => 18, "variants" => "\"\"", "position" => 0, + "images" => null, "model" => "23", "sku" => "231", "price" => 324, @@ -932,13 +1221,13 @@ class ProductsSeeder extends Seeder "cost_price" => 43, "quantity" => 546, "is_default" => 1, - "images" => null ], [ "id" => 17, "product_id" => 19, "variants" => "\"\"", "position" => 0, + "images" => null, "model" => "23", "sku" => "231", "price" => 324, @@ -946,13 +1235,13 @@ class ProductsSeeder extends Seeder "cost_price" => 43, "quantity" => 546, "is_default" => 1, - "images" => null ], [ "id" => 18, "product_id" => 20, "variants" => "\"\"", "position" => 0, + "images" => null, "model" => "23", "sku" => "231", "price" => 324, @@ -960,125 +1249,13 @@ class ProductsSeeder extends Seeder "cost_price" => 43, "quantity" => 546, "is_default" => 1, - "images" => null - ], - [ - "id" => 44, - "product_id" => 2, - "variants" => "\"\"", - "position" => 0, - "model" => "23", - "sku" => "231", - "price" => 324, - "origin_price" => 35, - "cost_price" => 43, - "quantity" => 546, - "is_default" => 1, - "images" => null - ], - [ - "id" => 45, - "product_id" => 3, - "variants" => "\"\"", - "position" => 0, - "model" => "dpfiv-fdsf", - "sku" => "dfufuuivvvvb", - "price" => 299, - "origin_price" => 299, - "cost_price" => 1992, - "quantity" => 444, - "is_default" => 1, - "images" => null - ], - [ - "id" => 49, - "product_id" => 7, - "variants" => "\"\"", - "position" => 0, - "model" => "fvhk-fds-fsdf-", - "sku" => "fofofd--ffgg--", - "price" => 99, - "origin_price" => 299, - "cost_price" => 299, - "quantity" => 3333, - "is_default" => 1, - "images" => null - ], - [ - "id" => 51, - "product_id" => 9, - "variants" => "\"\"", - "position" => 0, - "model" => "4809328", - "sku" => "ufsfsdf898=", - "price" => 299, - "origin_price" => 999, - "cost_price" => 99, - "quantity" => 99, - "is_default" => 1, - "images" => null - ], - [ - "id" => 53, - "product_id" => 11, - "variants" => "\"\"", - "position" => 0, - "model" => "fyuydf99f", - "sku" => "vusodiuhv", - "price" => 98, - "origin_price" => 234, - "cost_price" => 223, - "quantity" => 2223, - "is_default" => 1, - "images" => null - ], - [ - "id" => 54, - "product_id" => 12, - "variants" => "\"\"", - "position" => 0, - "model" => "fsd8g8g7", - "sku" => "pridhyyyii", - "price" => 79, - "origin_price" => 222, - "cost_price" => 333, - "quantity" => 2222, - "is_default" => 1, - "images" => null - ], - [ - "id" => 55, - "product_id" => 13, - "variants" => "\"\"", - "position" => 0, - "model" => "vdvs-gdg-ff", - "sku" => "ddf00dfhsdkjvv", - "price" => 199, - "origin_price" => 333, - "cost_price" => 333, - "quantity" => 3445, - "is_default" => 1, - "images" => null - ], - [ - "id" => 56, - "product_id" => 14, - "variants" => "\"\"", - "position" => 0, - "model" => "csdfsdf", - "sku" => "fffaaacsdsf", - "price" => 299, - "origin_price" => 433, - "cost_price" => 234, - "quantity" => 423, - "is_default" => 1, - "images" => null ], [ "id" => 62, "product_id" => 28, "variants" => "\"\"", "position" => 0, + "images" => null, "model" => "3", "sku" => "123", "price" => 213, @@ -1086,13 +1263,13 @@ class ProductsSeeder extends Seeder "cost_price" => 213, "quantity" => 213, "is_default" => 1, - "images" => null ], [ "id" => 63, "product_id" => 30, "variants" => "\"\"", "position" => 0, + "images" => null, "model" => "1", "sku" => "1", "price" => 30, @@ -1100,13 +1277,13 @@ class ProductsSeeder extends Seeder "cost_price" => 10, "quantity" => 10, "is_default" => 1, - "images" => null ], [ "id" => 67, "product_id" => 31, "variants" => "\"\"", "position" => 0, + "images" => null, "model" => "121", "sku" => "1212", "price" => 20.99, @@ -1114,13 +1291,13 @@ class ProductsSeeder extends Seeder "cost_price" => 20.99, "quantity" => 999, "is_default" => 1, - "images" => null ], [ "id" => 71, "product_id" => 34, "variants" => "\"\"", "position" => 0, + "images" => null, "model" => "1", "sku" => "089888", "price" => 20, @@ -1128,13 +1305,13 @@ class ProductsSeeder extends Seeder "cost_price" => 10, "quantity" => 999, "is_default" => 1, - "images" => null ], [ "id" => 80, "product_id" => 32, "variants" => "\"\"", "position" => 0, + "images" => null, "model" => "Q", "sku" => "1", "price" => 199999.99, @@ -1142,125 +1319,13 @@ class ProductsSeeder extends Seeder "cost_price" => 100, "quantity" => 999, "is_default" => 1, - "images" => null ], [ - "id" => 141, - "product_id" => 6, - "variants" => "\"\"", - "position" => 0, - "model" => "3123", - "sku" => "cdsvfdbbbbbbb", - "price" => 423, - "origin_price" => 44232, - "cost_price" => 3, - "quantity" => 123123, - "is_default" => 1, - "images" => null - ], - [ - "id" => 227, - "product_id" => 39, - "variants" => "[\"0\", \"0\"]", - "position" => 0, - "model" => "1", - "sku" => "089888", - "price" => 100, - "origin_price" => 3534, - "cost_price" => 3453, - "quantity" => 999, - "is_default" => 1, - "images" => "[\"catalog/demo/product/12.jpg\"]" - ], - [ - "id" => 228, - "product_id" => 39, - "variants" => "[\"0\", \"1\"]", - "position" => 1, - "model" => "2", - "sku" => "s", - "price" => 56, - "origin_price" => 353, - "cost_price" => 454, - "quantity" => 454, - "is_default" => 0, - "images" => "[\"catalog/demo/product/15.jpg\"]" - ], - [ - "id" => 229, - "product_id" => 39, - "variants" => "[\"1\", \"0\"]", - "position" => 2, - "model" => "3", - "sku" => "sd", - "price" => 454, - "origin_price" => 353, - "cost_price" => 345, - "quantity" => 45, - "is_default" => 0, - "images" => "[\"catalog/demo/product/18.jpg\"]" - ], - [ - "id" => 230, - "product_id" => 39, - "variants" => "[\"1\", \"1\"]", - "position" => 3, - "model" => "4", - "sku" => "dsfds", - "price" => 3534, - "origin_price" => 353, - "cost_price" => 4545, - "quantity" => 45, - "is_default" => 0, - "images" => "[\"catalog/demo/product/4.jpg\"]" - ], - [ - "id" => 231, - "product_id" => 35, - "variants" => "\"\"", - "position" => 0, - "model" => "1", - "sku" => "1", - "price" => 100.99, - "origin_price" => 50.99, - "cost_price" => 30.99, - "quantity" => 999, - "is_default" => 1, - "images" => null - ], - [ - "id" => 232, - "product_id" => 4, - "variants" => "\"\"", - "position" => 0, - "model" => "cufjjppvd-", - "sku" => "ososividsuio", - "price" => 99, - "origin_price" => 333, - "cost_price" => 333, - "quantity" => 333, - "is_default" => 1, - "images" => null - ], - [ - "id" => 233, - "product_id" => 8, - "variants" => "\"\"", - "position" => 0, - "model" => "dsd989f", - "sku" => "fidfivifuiuifff", - "price" => 99, - "origin_price" => 333, - "cost_price" => 222, - "quantity" => 2222, - "is_default" => 1, - "images" => null - ], - [ - "id" => 234, + "id" => 273, "product_id" => 5, "variants" => "\"\"", "position" => 0, + "images" => null, "model" => "3123", "sku" => "3vjdfsl-jv-klsj", "price" => 999, @@ -1268,13 +1333,69 @@ class ProductsSeeder extends Seeder "cost_price" => 222, "quantity" => 42131, "is_default" => 1, - "images" => null ], [ - "id" => 235, + "id" => 274, + "product_id" => 6, + "variants" => "\"\"", + "position" => 0, + "images" => null, + "model" => "3123", + "sku" => "cdsvfdbbbbbbb", + "price" => 423, + "origin_price" => 44232, + "cost_price" => 3, + "quantity" => 123123, + "is_default" => 1, + ], + [ + "id" => 275, + "product_id" => 7, + "variants" => "\"\"", + "position" => 0, + "images" => null, + "model" => "fvhk-fds-fsdf-", + "sku" => "fofofd--ffgg--", + "price" => 99, + "origin_price" => 299, + "cost_price" => 299, + "quantity" => 3333, + "is_default" => 1, + ], + [ + "id" => 276, + "product_id" => 8, + "variants" => "\"\"", + "position" => 0, + "images" => null, + "model" => "dsd989f", + "sku" => "fidfivifuiuifff", + "price" => 99, + "origin_price" => 333, + "cost_price" => 222, + "quantity" => 2222, + "is_default" => 1, + ], + [ + "id" => 277, + "product_id" => 9, + "variants" => "\"\"", + "position" => 0, + "images" => null, + "model" => "4809328", + "sku" => "ufsfsdf898=", + "price" => 299, + "origin_price" => 999, + "cost_price" => 99, + "quantity" => 99, + "is_default" => 1, + ], + [ + "id" => 278, "product_id" => 10, "variants" => "\"\"", "position" => 0, + "images" => null, "model" => "2312", "sku" => "312", "price" => 169, @@ -1282,69 +1403,69 @@ class ProductsSeeder extends Seeder "cost_price" => 55, "quantity" => 33, "is_default" => 1, - "images" => null ], [ - "id" => 236, - "product_id" => 1, - "variants" => "[\"0\", \"0\"]", + "id" => 279, + "product_id" => 11, + "variants" => "\"\"", "position" => 0, - "model" => "YL", - "sku" => "yl1234", - "price" => 88.3, - "origin_price" => 2312, - "cost_price" => 2312, + "images" => null, + "model" => "fyuydf99f", + "sku" => "vusodiuhv", + "price" => 98, + "origin_price" => 234, + "cost_price" => 223, + "quantity" => 2223, + "is_default" => 1, + ], + [ + "id" => 280, + "product_id" => 12, + "variants" => "\"\"", + "position" => 0, + "images" => null, + "model" => "fsd8g8g7", + "sku" => "pridhyyyii", + "price" => 79, + "origin_price" => 222, + "cost_price" => 333, "quantity" => 2222, "is_default" => 1, - "images" => "[\"catalog/demo/product/17.jpg\"]" ], [ - "id" => 237, - "product_id" => 1, - "variants" => "[\"0\", \"1\"]", - "position" => 1, - "model" => "YM", - "sku" => "ym1234", - "price" => 448.3, - "origin_price" => 2312, - "cost_price" => 2312, - "quantity" => 0, - "is_default" => 0, - "images" => "[\"catalog/demo/product/10.jpg\"]" + "id" => 281, + "product_id" => 13, + "variants" => "\"\"", + "position" => 0, + "images" => null, + "model" => "vdvs-gdg-ff", + "sku" => "ddf00dfhsdkjvv", + "price" => 199, + "origin_price" => 333, + "cost_price" => 333, + "quantity" => 3445, + "is_default" => 1, ], [ - "id" => 238, - "product_id" => 1, - "variants" => "[\"1\", \"0\"]", - "position" => 2, - "model" => "GL", - "sku" => "gl123", - "price" => 18.3, - "origin_price" => 2312, - "cost_price" => 2312, - "quantity" => 22, - "is_default" => 0, - "images" => "[\"catalog/demo/product/17.jpg\"]" + "id" => 282, + "product_id" => 14, + "variants" => "\"\"", + "position" => 0, + "images" => null, + "model" => "csdfsdf", + "sku" => "fffaaacsdsf", + "price" => 299, + "origin_price" => 433, + "cost_price" => 234, + "quantity" => 423, + "is_default" => 1, ], [ - "id" => 239, - "product_id" => 1, - "variants" => "[\"1\", \"1\"]", - "position" => 3, - "model" => "GM", - "sku" => "gm123", - "price" => 78.3, - "origin_price" => 2312, - "cost_price" => 2312, - "quantity" => 3333, - "is_default" => 0, - "images" => "[\"catalog/demo/product/10.jpg\"]" - ], - [ - "id" => 240, + "id" => 283, "product_id" => 15, "variants" => "\"\"", "position" => 0, + "images" => null, "model" => "dsfs90fff-", "sku" => "ff-ggs-eeerrtt", "price" => 324, @@ -1352,8 +1473,537 @@ class ProductsSeeder extends Seeder "cost_price" => 43, "quantity" => 546, "is_default" => 1, - "images" => null ], + [ + "id" => 284, + "product_id" => 35, + "variants" => "\"\"", + "position" => 0, + "images" => null, + "model" => "1", + "sku" => "1", + "price" => 100.99, + "origin_price" => 50.99, + "cost_price" => 30.99, + "quantity" => 999, + "is_default" => 1, + ], + [ + "id" => 285, + "product_id" => 39, + "variants" => "[\"0\", \"0\"]", + "position" => 0, + "images" => "[\"catalog/demo/product/12.jpg\"]", + "model" => "1", + "sku" => "089888", + "price" => 100, + "origin_price" => 3534, + "cost_price" => 3453, + "quantity" => 999, + "is_default" => 1, + ], + [ + "id" => 286, + "product_id" => 39, + "variants" => "[\"0\", \"1\"]", + "position" => 1, + "images" => "[\"catalog/demo/product/15.jpg\"]", + "model" => "2", + "sku" => "s", + "price" => 56, + "origin_price" => 353, + "cost_price" => 454, + "quantity" => 454, + "is_default" => 0, + ], + [ + "id" => 287, + "product_id" => 39, + "variants" => "[\"1\", \"0\"]", + "position" => 2, + "images" => "[\"catalog/demo/product/18.jpg\"]", + "model" => "3", + "sku" => "sd", + "price" => 454, + "origin_price" => 353, + "cost_price" => 345, + "quantity" => 45, + "is_default" => 0, + ], + [ + "id" => 288, + "product_id" => 39, + "variants" => "[\"1\", \"1\"]", + "position" => 3, + "images" => "[\"catalog/demo/product/4.jpg\"]", + "model" => "4", + "sku" => "dsfds", + "price" => 3534, + "origin_price" => 353, + "cost_price" => 4545, + "quantity" => 45, + "is_default" => 0, + ], + [ + "id" => 289, + "product_id" => 1, + "variants" => "[\"0\", \"0\"]", + "position" => 0, + "images" => "[\"catalog/demo/product/17.jpg\"]", + "model" => "YL", + "sku" => "yl1234", + "price" => 88.3, + "origin_price" => 2312, + "cost_price" => 2312, + "quantity" => 2222, + "is_default" => 1, + ], + [ + "id" => 290, + "product_id" => 1, + "variants" => "[\"0\", \"1\"]", + "position" => 1, + "images" => "[\"catalog/demo/product/10.jpg\"]", + "model" => "YM", + "sku" => "ym1234", + "price" => 448.3, + "origin_price" => 2312, + "cost_price" => 2312, + "quantity" => 0, + "is_default" => 0, + ], + [ + "id" => 291, + "product_id" => 1, + "variants" => "[\"1\", \"0\"]", + "position" => 2, + "images" => "[\"catalog/demo/product/17.jpg\"]", + "model" => "GL", + "sku" => "gl123", + "price" => 18.3, + "origin_price" => 2312, + "cost_price" => 2312, + "quantity" => 22, + "is_default" => 0, + ], + [ + "id" => 292, + "product_id" => 1, + "variants" => "[\"1\", \"1\"]", + "position" => 3, + "images" => "[\"catalog/demo/product/10.jpg\"]", + "model" => "GM", + "sku" => "gm123", + "price" => 78.3, + "origin_price" => 2312, + "cost_price" => 2312, + "quantity" => 3333, + "is_default" => 0, + ], + [ + "id" => 299, + "product_id" => 2, + "variants" => "[\"0\", \"0\"]", + "position" => 0, + "images" => "[\"catalog/demo/product/13.jpg\"]", + "model" => "23", + "sku" => "231", + "price" => 324, + "origin_price" => 213, + "cost_price" => 312, + "quantity" => 546, + "is_default" => 1, + ], + [ + "id" => 300, + "product_id" => 2, + "variants" => "[\"0\", \"1\"]", + "position" => 1, + "images" => "[\"catalog/demo/product/2.jpg\"]", + "model" => "213", + "sku" => "dbge1-ff", + "price" => 231, + "origin_price" => 213, + "cost_price" => 31, + "quantity" => 2312, + "is_default" => 0, + ], + [ + "id" => 301, + "product_id" => 2, + "variants" => "[\"1\", \"0\"]", + "position" => 2, + "images" => null, + "model" => "dsfdsf", + "sku" => "sd-c-s-2", + "price" => 123, + "origin_price" => 3123, + "cost_price" => 23, + "quantity" => 432, + "is_default" => 0, + ], + [ + "id" => 302, + "product_id" => 2, + "variants" => "[\"1\", \"1\"]", + "position" => 3, + "images" => null, + "model" => "dsf1", + "sku" => "ss11c-s-2", + "price" => 542, + "origin_price" => 12321, + "cost_price" => 123, + "quantity" => 555, + "is_default" => 0, + ], + [ + "id" => 303, + "product_id" => 2, + "variants" => "[\"2\", \"0\"]", + "position" => 4, + "images" => null, + "model" => "b1231", + "sku" => "cca22bb4", + "price" => 671, + "origin_price" => 213, + "cost_price" => 123, + "quantity" => 12, + "is_default" => 0, + ], + [ + "id" => 304, + "product_id" => 2, + "variants" => "[\"2\", \"1\"]", + "position" => 5, + "images" => null, + "model" => "123", + "sku" => "puddw21-121", + "price" => 231, + "origin_price" => 12, + "cost_price" => 213123, + "quantity" => 31231, + "is_default" => 0, + ], + [ + "id" => 305, + "product_id" => 3, + "variants" => "[\"0\", \"0\"]", + "position" => 0, + "images" => "[\"catalog/demo/product/11.jpg\"]", + "model" => "dpfiv-fdsf", + "sku" => "dfufuuivvvvb", + "price" => 299, + "origin_price" => 312312, + "cost_price" => 311, + "quantity" => 444, + "is_default" => 1, + ], + [ + "id" => 306, + "product_id" => 3, + "variants" => "[\"0\", \"1\"]", + "position" => 1, + "images" => "[\"catalog/demo/product/12.jpg\"]", + "model" => "4s-sd", + "sku" => "cas-vv-11a-", + "price" => 123, + "origin_price" => 321, + "cost_price" => 451, + "quantity" => 312, + "is_default" => 0, + ], + [ + "id" => 307, + "product_id" => 3, + "variants" => "[\"1\", \"0\"]", + "position" => 2, + "images" => "[\"catalog/demo/product/11.jpg\"]", + "model" => "b14fiv-fdsf", + "sku" => "2212v-aa-", + "price" => 123, + "origin_price" => 312, + "cost_price" => 6423, + "quantity" => 312, + "is_default" => 0, + ], + [ + "id" => 308, + "product_id" => 3, + "variants" => "[\"1\", \"1\"]", + "position" => 3, + "images" => "[\"catalog/demo/product/12.jpg\"]", + "model" => "dpfiv-fdsf", + "sku" => "xccd-vv-aa-", + "price" => 775, + "origin_price" => 3, + "cost_price" => 123, + "quantity" => 0, + "is_default" => 0, + ], + [ + "id" => 309, + "product_id" => 3, + "variants" => "[\"2\", \"0\"]", + "position" => 4, + "images" => "[\"catalog/demo/product/11.jpg\"]", + "model" => "5giv-fdpho", + "sku" => "sa112-vv-aa-", + "price" => 313, + "origin_price" => 32, + "cost_price" => 14423, + "quantity" => 333, + "is_default" => 0, + ], + [ + "id" => 310, + "product_id" => 3, + "variants" => "[\"2\", \"1\"]", + "position" => 5, + "images" => "[\"catalog/demo/product/12.jpg\"]", + "model" => "s22pfiv-fdsf", + "sku" => "x99asv-aa-", + "price" => 2349, + "origin_price" => 435, + "cost_price" => 434, + "quantity" => 111, + "is_default" => 0, + ], + [ + "id" => 311, + "product_id" => 3, + "variants" => "[\"3\", \"0\"]", + "position" => 6, + "images" => "[\"catalog/demo/product/11.jpg\"]", + "model" => "dpfiv-fdsf", + "sku" => "cas-ddd11a-", + "price" => 2349, + "origin_price" => 4678, + "cost_price" => 654, + "quantity" => 0, + "is_default" => 0, + ], + [ + "id" => 312, + "product_id" => 3, + "variants" => "[\"3\", \"1\"]", + "position" => 7, + "images" => "[\"catalog/demo/product/12.jpg\"]", + "model" => "dpfiv-fdsf", + "sku" => "22222as-vv-aa-", + "price" => 1299, + "origin_price" => 6578, + "cost_price" => 123, + "quantity" => 11, + "is_default" => 0, + ], + [ + "id" => 313, + "product_id" => 4, + "variants" => "[\"0\", \"0\"]", + "position" => 0, + "images" => null, + "model" => "cufjjppvd-", + "sku" => "ososividsuio", + "price" => 99, + "origin_price" => 123, + "cost_price" => 312, + "quantity" => 333, + "is_default" => 1, + ], + [ + "id" => 314, + "product_id" => 4, + "variants" => "[\"0\", \"1\"]", + "position" => 1, + "images" => null, + "model" => "d11-f123", + "sku" => "eqw", + "price" => 23, + "origin_price" => 33, + "cost_price" => 312, + "quantity" => 123, + "is_default" => 0, + ], + [ + "id" => 315, + "product_id" => 4, + "variants" => "[\"1\", \"0\"]", + "position" => 2, + "images" => null, + "model" => "d123-vsf123-312", + "sku" => "eqw123", + "price" => 34, + "origin_price" => 123, + "cost_price" => 3, + "quantity" => 33, + "is_default" => 0, + ], + [ + "id" => 316, + "product_id" => 4, + "variants" => "[\"1\", \"1\"]", + "position" => 3, + "images" => null, + "model" => "99-123d", + "sku" => "412312", + "price" => 55, + "origin_price" => 13, + "cost_price" => 32112, + "quantity" => 3312, + "is_default" => 0, + ], + [ + "id" => 317, + "product_id" => 4, + "variants" => "[\"2\", \"0\"]", + "position" => 4, + "images" => null, + "model" => "kkd99-123d", + "sku" => "4123", + "price" => 66, + "origin_price" => 2312, + "cost_price" => 32, + "quantity" => 3, + "is_default" => 0, + ], + [ + "id" => 318, + "product_id" => 4, + "variants" => "[\"2\", \"1\"]", + "position" => 5, + "images" => null, + "model" => "423-vsf123", + "sku" => "35436fsd", + "price" => 77, + "origin_price" => 13, + "cost_price" => 123, + "quantity" => 3312, + "is_default" => 0, + ], + [ + "id" => 319, + "product_id" => 4, + "variants" => "[\"3\", \"0\"]", + "position" => 6, + "images" => null, + "model" => "s123-v-sf123", + "sku" => "45fds31", + "price" => 113, + "origin_price" => 123, + "cost_price" => 213, + "quantity" => 33, + "is_default" => 0, + ], + [ + "id" => 320, + "product_id" => 4, + "variants" => "[\"3\", \"1\"]", + "position" => 7, + "images" => null, + "model" => "c8ad0-fsd1", + "sku" => "756assdfsf", + "price" => 33, + "origin_price" => 3123, + "cost_price" => 3, + "quantity" => 3123, + "is_default" => 0, + ] + ]; + } + + private function getProductRelations(): array + { + return [ + ["product_id" => 1, "relation_id" => 1,], + ["product_id" => 1, "relation_id" => 2,], + ["product_id" => 1, "relation_id" => 3,], + ["product_id" => 1, "relation_id" => 5,], + ["product_id" => 1, "relation_id" => 6,], + ["product_id" => 1, "relation_id" => 8,], + ["product_id" => 4, "relation_id" => 1,], + ["product_id" => 4, "relation_id" => 2,], + ["product_id" => 4, "relation_id" => 3,], + ["product_id" => 4, "relation_id" => 4,], + ["product_id" => 4, "relation_id" => 6,], + ["product_id" => 4, "relation_id" => 7,], + ["product_id" => 4, "relation_id" => 10,], + ["product_id" => 6, "relation_id" => 1,], + ["product_id" => 6, "relation_id" => 2,], + ["product_id" => 6, "relation_id" => 4,], + ["product_id" => 6, "relation_id" => 10,], + ["product_id" => 39, "relation_id" => 1,], + ["product_id" => 39, "relation_id" => 2,], + ["product_id" => 39, "relation_id" => 3,], + ["product_id" => 39, "relation_id" => 4,], + ["product_id" => 39, "relation_id" => 5,], + ["product_id" => 39, "relation_id" => 7,], + ["product_id" => 39, "relation_id" => 9,], + ["product_id" => 35, "relation_id" => 1,], + ["product_id" => 35, "relation_id" => 2,], + ["product_id" => 35, "relation_id" => 3,], + ["product_id" => 35, "relation_id" => 4,], + ["product_id" => 35, "relation_id" => 7,], + ["product_id" => 35, "relation_id" => 8,], + ["product_id" => 35, "relation_id" => 10,], + ["product_id" => 15, "relation_id" => 1,], + ["product_id" => 15, "relation_id" => 2,], + ["product_id" => 15, "relation_id" => 3,], + ["product_id" => 15, "relation_id" => 8,], + ["product_id" => 15, "relation_id" => 9,], + ["product_id" => 14, "relation_id" => 10,], + ["product_id" => 14, "relation_id" => 9,], + ["product_id" => 14, "relation_id" => 8,], + ["product_id" => 14, "relation_id" => 7,], + ["product_id" => 14, "relation_id" => 6,], + ["product_id" => 14, "relation_id" => 5,], + ["product_id" => 13, "relation_id" => 7,], + ["product_id" => 13, "relation_id" => 10,], + ["product_id" => 13, "relation_id" => 9,], + ["product_id" => 13, "relation_id" => 8,], + ["product_id" => 13, "relation_id" => 4,], + ["product_id" => 13, "relation_id" => 2,], + ["product_id" => 12, "relation_id" => 5,], + ["product_id" => 12, "relation_id" => 1,], + ["product_id" => 12, "relation_id" => 2,], + ["product_id" => 12, "relation_id" => 9,], + ["product_id" => 12, "relation_id" => 10,], + ["product_id" => 12, "relation_id" => 7,], + ["product_id" => 11, "relation_id" => 1,], + ["product_id" => 11, "relation_id" => 2,], + ["product_id" => 11, "relation_id" => 3,], + ["product_id" => 11, "relation_id" => 7,], + ["product_id" => 11, "relation_id" => 9,], + ["product_id" => 10, "relation_id" => 9,], + ["product_id" => 10, "relation_id" => 6,], + ["product_id" => 10, "relation_id" => 10,], + ["product_id" => 10, "relation_id" => 4,], + ["product_id" => 10, "relation_id" => 1,], + ["product_id" => 10, "relation_id" => 7,], + ["product_id" => 9, "relation_id" => 2,], + ["product_id" => 9, "relation_id" => 4,], + ["product_id" => 9, "relation_id" => 8,], + ["product_id" => 9, "relation_id" => 9,], + ["product_id" => 9, "relation_id" => 10,], + ["product_id" => 8, "relation_id" => 1,], + ["product_id" => 8, "relation_id" => 2,], + ["product_id" => 8, "relation_id" => 3,], + ["product_id" => 8, "relation_id" => 4,], + ["product_id" => 8, "relation_id" => 9,], + ["product_id" => 7, "relation_id" => 5,], + ["product_id" => 7, "relation_id" => 8,], + ["product_id" => 7, "relation_id" => 10,], + ["product_id" => 7, "relation_id" => 4,], + ["product_id" => 7, "relation_id" => 1,], + ["product_id" => 5, "relation_id" => 1,], + ["product_id" => 5, "relation_id" => 6,], + ["product_id" => 5, "relation_id" => 9,], + ["product_id" => 5, "relation_id" => 10,], + ["product_id" => 5, "relation_id" => 7,], + ["product_id" => 3, "relation_id" => 2,], + ["product_id" => 3, "relation_id" => 8,], + ["product_id" => 3, "relation_id" => 9,], + ["product_id" => 3, "relation_id" => 10,], + ["product_id" => 3, "relation_id" => 4,] ]; } }