label('SKU') ->exampleHeader('SKU') ->examples(['ABC123', 'DEF456']), ImportColumn::make('setup') ->rules(['max:20']) ->label('Setup Fee') ->exampleHeader('Setup Fee') ->example('40'), ImportColumn::make('lead_time') ->rules(['max:255']) ->label('Lead Time') ->exampleHeader('Lead Time') ->example('Despatched same day if order received before 1:30pm (if credit worthy)'), ImportColumn::make('description') ->rules(['max:255']) ->label('Description') ->exampleHeader('Description') ->example('Undecorated'), ImportColumn::make('magento_type') ->label('Website Decoration') ->exampleHeader('Website Decoration') ->example('Un-branded') ->rules(['max:255']), ]; } public static function getCompletedNotificationBody(Import $import): string { $body = 'Your product variant import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.'; if ($failedRowsCount = $import->getFailedRowsCount()) { $body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.'; } return $body; } public function resolveRecord(): ?ProductVariant { $productVariant = new ProductVariant; $sku = $this->data['sku']; $explode = explode('-', $sku); $end = end($explode); $promodataId = is_numeric($end) ? $end : null; $product=Product::where('promodata_id', $promodataId)->first(); $key = Str::uuid()->toString(); $productVariant->supplier_id = $product->supplier_id; $productVariant->product_id = $product->id; $productVariant->product_id_key= $product->id . '-' . $key; $productVariant->key = $key; $productVariant->free = null; $productVariant->tags = null; $productVariant->type = $this->data['magento_type']; $productVariant->indent = null; $productVariant->currency = 'AUD'; $productVariant->undecorated =1; $productVariant->variant_type ='BasePrice'; $productVariant->details = null; $productVariant->is_archived = 0; $productVariant->is_custom_deco_flag =1; unset($this->data['sku']); return $productVariant; } }