@@ -616,6 +616,83 @@ public function testIsRowValid()
616616 }
617617 }
618618
619+ public function testRowValidationForNumericalSkus ()
620+ {
621+ // Set _attributes to avoid error in Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType.
622+ $ this ->setPropertyValue ($ this ->configurable , '_attributes ' , [
623+ 'Default ' => [],
624+ ]);
625+ // Avoiding errors about attributes not being super
626+ $ this ->setPropertyValue (
627+ $ this ->configurable ,
628+ '_superAttributes ' ,
629+ [
630+ 'testattr2 ' => [
631+ 'options ' => [
632+ 'attr2val1 ' => 1 ,
633+ 'attr2val2 ' => 2 ,
634+ ]
635+ ],
636+ ]
637+ );
638+
639+ $ rowValidationDataProvider = $ this ->rowValidationDataProvider ();
640+
641+ // Checking that variations with duplicate sku are invalid
642+ $ result = $ this ->configurable ->isRowValid ($ rowValidationDataProvider ['duplicateProduct ' ], 0 );
643+ $ this ->assertFalse ($ result );
644+
645+ // Checking that variations with SKUs that are the same when interpreted as number,
646+ // but different when interpreted as string are valid
647+ $ result = $ this ->configurable ->isRowValid ($ rowValidationDataProvider ['nonDuplicateProduct ' ], 0 );
648+ $ this ->assertTrue ($ result );
649+ }
650+
651+ /**
652+ * @return array
653+ */
654+ public function rowValidationDataProvider ()
655+ {
656+ return [
657+ 'duplicateProduct ' => [
658+ 'sku ' => 'configurableNumericalSkuDuplicateVariation ' ,
659+ 'store_view_code ' => null ,
660+ 'attribute_set_code ' => 'Default ' ,
661+ 'product_type ' => 'configurable ' ,
662+ 'name ' => 'Configurable Product with duplicate numerical SKUs in variations ' ,
663+ 'product_websites ' => 'website_1 ' ,
664+ 'configurable_variation_labels ' => 'testattr2=Select Configuration ' ,
665+ 'configurable_variations ' => 'sku=1234.1, '
666+ . 'testattr2=attr2val1, '
667+ . 'display=1|sku=1234.1, '
668+ . 'testattr2=attr2val1, '
669+ . 'display=0 ' ,
670+ '_store ' => null ,
671+ '_attribute_set ' => 'Default ' ,
672+ '_type ' => 'configurable ' ,
673+ '_product_websites ' => 'website_1 ' ,
674+ ],
675+ 'nonDuplicateProduct ' => [
676+ 'sku ' => 'configurableNumericalSkuNonDuplicateVariation ' ,
677+ 'store_view_code ' => null ,
678+ 'attribute_set_code ' => 'Default ' ,
679+ 'product_type ' => 'configurable ' ,
680+ 'name ' => 'Configurable Product with different numerical SKUs in variations ' ,
681+ 'product_websites ' => 'website_1 ' ,
682+ 'configurable_variation_labels ' => 'testattr2=Select Configuration ' ,
683+ 'configurable_variations ' => 'sku=1234.10, '
684+ . 'testattr2=attr2val1, '
685+ . 'display=1|sku=1234.1, '
686+ . 'testattr2=attr2val2, '
687+ . 'display=0 ' ,
688+ '_store ' => null ,
689+ '_attribute_set ' => 'Default ' ,
690+ '_type ' => 'configurable ' ,
691+ '_product_websites ' => 'website_1 ' ,
692+ ]
693+ ];
694+ }
695+
619696 /**
620697 * Set object property value.
621698 *
0 commit comments