@@ -586,55 +586,8 @@ public function testIsRowValid()
586
586
'_type ' => 'configurable ' ,
587
587
'_product_websites ' => 'website_1 ' ,
588
588
];
589
- // Checking that variations with duplicate sku are invalid
590
- $ duplicateSKU = 'configurableskuI22DuplicateVariation ' ;
591
- $ duplicateProduct = [
592
- 'sku ' => $ duplicateSKU ,
593
- 'store_view_code ' => null ,
594
- 'attribute_set_code ' => 'Default ' ,
595
- 'product_type ' => 'configurable ' ,
596
- 'name ' => 'Configurable Product with duplicate SKUs in variations ' ,
597
- 'product_websites ' => 'website_1 ' ,
598
- 'configurable_variation_labels ' => 'testattr2=Select Color, testattr3=Select Size ' ,
599
- 'configurable_variations ' => 'sku=testconf2-attr2val1-testattr3v1, '
600
- . 'testattr2=attr2val1, '
601
- . 'testattr3=testattr3v1, '
602
- . 'display=1|sku=testconf2-attr2val1-testattr3v1, '
603
- . 'testattr2=attr2val1, '
604
- . 'testattr3=testattr3v2, '
605
- . 'display=0 ' ,
606
- '_store ' => null ,
607
- '_attribute_set ' => 'Default ' ,
608
- '_type ' => 'configurable ' ,
609
- '_product_websites ' => 'website_1 ' ,
610
- ];
611
- // Checking that variations with SKUs that are the same when interpreted as number,
612
- // but different when interpreted as string are valid
613
- $ nonDuplicateSKU = 'configurableskuI22NonDuplicateVariation ' ;
614
- $ nonDuplicateProduct = [
615
- 'sku ' => $ nonDuplicateSKU ,
616
- 'store_view_code ' => null ,
617
- 'attribute_set_code ' => 'Default ' ,
618
- 'product_type ' => 'configurable ' ,
619
- 'name ' => 'Configurable Product with different SKUs in variations ' ,
620
- 'product_websites ' => 'website_1 ' ,
621
- 'configurable_variation_labels ' => 'testattr2=Select Color, testattr3=Select Size ' ,
622
- 'configurable_variations ' => 'sku=1234.10, '
623
- . 'testattr2=attr2val1, '
624
- . 'testattr3=testattr3v1, '
625
- . 'display=1|sku=1234.1, '
626
- . 'testattr2=attr2val1, '
627
- . 'testattr3=testattr3v2, '
628
- . 'display=0 ' ,
629
- '_store ' => null ,
630
- '_attribute_set ' => 'Default ' ,
631
- '_type ' => 'configurable ' ,
632
- '_product_websites ' => 'website_1 ' ,
633
- ];
634
589
$ bunch [] = $ badProduct ;
635
590
$ bunch [] = $ caseInsensitiveProduct ;
636
- $ bunch [] = $ duplicateProduct ;
637
- $ bunch [] = $ nonDuplicateProduct ;
638
591
// Set _attributes to avoid error in Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType.
639
592
$ this ->setPropertyValue ($ this ->configurable , '_attributes ' , [
640
593
$ badProduct [\Magento \CatalogImportExport \Model \Import \Product::COL_ATTR_SET ] => [],
@@ -660,15 +613,41 @@ public function testIsRowValid()
660
613
if ($ rowData ['sku ' ] === $ caseInsensitiveSKU ) {
661
614
$ this ->assertTrue ($ result );
662
615
}
663
- if ($ rowData ['sku ' ] === $ duplicateSKU ) {
664
- $ this ->assertFalse ($ result );
665
- }
666
- if ($ rowData ['sku ' ] === $ nonDuplicateSKU ) {
667
- $ this ->assertTrue ($ result );
668
- }
669
616
}
670
617
}
671
618
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
+ // Checking that variations with duplicate sku are invalid
640
+ $ duplicateProduct = $ this ->_getNumericalSkuDataDuplicate ();
641
+ $ result = $ this ->configurable ->isRowValid ($ duplicateProduct , 0 );
642
+ $ this ->assertFalse ($ result );
643
+
644
+ // Checking that variations with SKUs that are the same when interpreted as number,
645
+ // but different when interpreted as string are valid
646
+ $ nonDuplicateProduct = $ this ->_getNumericalSkuDataNonDuplicate ();
647
+ $ result = $ this ->configurable ->isRowValid ($ nonDuplicateProduct , 0 );
648
+ $ this ->assertTrue ($ result );
649
+ }
650
+
672
651
/**
673
652
* Set object property value.
674
653
*
@@ -685,4 +664,54 @@ protected function setPropertyValue(&$object, $property, $value)
685
664
686
665
return $ object ;
687
666
}
667
+
668
+ /**
669
+ * @return array
670
+ */
671
+ protected function _getNumericalSkuDataNonDuplicate (): array
672
+ {
673
+ return [
674
+ 'sku ' => 'configurableNumericalSkuNonDuplicateVariation ' ,
675
+ 'store_view_code ' => null ,
676
+ 'attribute_set_code ' => 'Default ' ,
677
+ 'product_type ' => 'configurable ' ,
678
+ 'name ' => 'Configurable Product with different numerical SKUs in variations ' ,
679
+ 'product_websites ' => 'website_1 ' ,
680
+ 'configurable_variation_labels ' => 'testattr2=Select Configuration ' ,
681
+ 'configurable_variations ' => 'sku=1234.10, '
682
+ . 'testattr2=attr2val1, '
683
+ . 'display=1|sku=1234.1, '
684
+ . 'testattr2=attr2val2, '
685
+ . 'display=0 ' ,
686
+ '_store ' => null ,
687
+ '_attribute_set ' => 'Default ' ,
688
+ '_type ' => 'configurable ' ,
689
+ '_product_websites ' => 'website_1 ' ,
690
+ ];
691
+ }
692
+
693
+ /**
694
+ * @return array
695
+ */
696
+ protected function _getNumericalSkuDataDuplicate (): array
697
+ {
698
+ return [
699
+ 'sku ' => 'configurableNumericalSkuDuplicateVariation ' ,
700
+ 'store_view_code ' => null ,
701
+ 'attribute_set_code ' => 'Default ' ,
702
+ 'product_type ' => 'configurable ' ,
703
+ 'name ' => 'Configurable Product with duplicate numerical SKUs in variations ' ,
704
+ 'product_websites ' => 'website_1 ' ,
705
+ 'configurable_variation_labels ' => 'testattr2=Select Configuration ' ,
706
+ 'configurable_variations ' => 'sku=1234.1, '
707
+ . 'testattr2=attr2val1, '
708
+ . 'display=1|sku=1234.1, '
709
+ . 'testattr2=attr2val1, '
710
+ . 'display=0 ' ,
711
+ '_store ' => null ,
712
+ '_attribute_set ' => 'Default ' ,
713
+ '_type ' => 'configurable ' ,
714
+ '_product_websites ' => 'website_1 ' ,
715
+ ];
716
+ }
688
717
}
0 commit comments