File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed
app/code/Magento/CatalogImportExport/Model/Import/Product Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -310,7 +310,11 @@ protected function isValidAttributes()
310
310
if ($ entityTypeModel ) {
311
311
foreach ($ this ->_rowData as $ attrCode => $ attrValue ) {
312
312
$ attrParams = $ entityTypeModel ->retrieveAttributeFromCache ($ attrCode );
313
- if ($ attrParams ) {
313
+ if ($ attrCode === Product::COL_CATEGORY ) {
314
+ if (!$ this ->isCategoriesValid ($ attrValue )) {
315
+ return false ;
316
+ }
317
+ } elseif ($ attrParams ) {
314
318
$ this ->isAttributeValid ($ attrCode , $ attrParams , $ this ->_rowData );
315
319
}
316
320
}
@@ -352,6 +356,30 @@ public function getRowScope(array $rowData)
352
356
return Product::SCOPE_STORE ;
353
357
}
354
358
359
+ /**
360
+ * Validate category names
361
+ *
362
+ * @param string $value
363
+ * @return bool
364
+ */
365
+ private function isCategoriesValid (string $ value ) : bool
366
+ {
367
+ $ result = true ;
368
+ if ($ value ) {
369
+ $ values = explode ($ this ->context ->getMultipleValueSeparator (), $ value );
370
+ foreach ($ values as $ categoryName ) {
371
+ if ($ result === true ) {
372
+ $ result = $ this ->string ->strlen ($ categoryName ) < Product::DB_MAX_VARCHAR_LENGTH ;
373
+ }
374
+ }
375
+ }
376
+ if ($ result === false ) {
377
+ $ this ->_addMessages ([RowValidatorInterface::ERROR_EXCEEDED_MAX_LENGTH ]);
378
+ $ this ->setInvalidAttribute (Product::COL_CATEGORY );
379
+ }
380
+ return $ result ;
381
+ }
382
+
355
383
/**
356
384
* Init
357
385
*
You can’t perform that action at this time.
0 commit comments