File tree Expand file tree Collapse file tree 1 file changed +32
-15
lines changed
app/code/Magento/CatalogImportExport/Model/Import/Product/Validator Expand file tree Collapse file tree 1 file changed +32
-15
lines changed Original file line number Diff line number Diff line change @@ -33,25 +33,42 @@ public function __construct(SkuStorage $skuStorage)
3333 public function isValid ($ value )
3434 {
3535 $ this ->_clearMessages ();
36- if (!$ this ->hasNameValue ($ value ) &&
37- !$ this ->hasCustomOptions ($ value ) &&
38- !$ this ->skuStorage ->has ($ value [Product::COL_SKU ]) &&
39- (!isset ($ value ['store_view_code ' ]) || $ value ['store_view_code ' ] === '' )
40- ) {
41- $ this ->_addMessages (
42- [
43- sprintf (
44- $ this ->context ->retrieveMessageTemplate (self ::ERROR_INVALID_ATTRIBUTE_TYPE ),
45- $ this ->fieldName ,
46- 'not empty '
47- )
48- ]
49- );
50- return false ;
36+
37+ $ skuExists = $ this ->skuStorage ->has ($ value [Product::COL_SKU ]);
38+ $ hasCustomOptions = $ this ->hasCustomOptions ($ value );
39+ $ hasNameValue = $ this ->hasNameValue ($ value );
40+ $ isStoreViewCodeEmpty = !isset ($ value ['store_view_code ' ]) || $ value ['store_view_code ' ] === '' ;
41+
42+ if (!$ skuExists && !$ hasCustomOptions && !$ hasNameValue ) {
43+ return $ this ->invalidate ();
44+ }
45+
46+ if (!$ hasNameValue && !$ hasCustomOptions && !$ skuExists && $ isStoreViewCodeEmpty ) {
47+ return $ this ->invalidate ();
5148 }
49+
5250 return true ;
5351 }
5452
53+ /**
54+ * Invalidate row data
55+ *
56+ * @return bool
57+ */
58+ private function invalidate (): bool
59+ {
60+ $ this ->_addMessages (
61+ [
62+ sprintf (
63+ $ this ->context ->retrieveMessageTemplate (self ::ERROR_INVALID_ATTRIBUTE_TYPE ),
64+ $ this ->fieldName ,
65+ 'not empty '
66+ )
67+ ]
68+ );
69+ return false ;
70+ }
71+
5572 /**
5673 * Check if row data contains name value
5774 *
You can’t perform that action at this time.
0 commit comments