Skip to content

Commit

Permalink
Fixing a bug that prevented products with a single attribute to be re…
Browse files Browse the repository at this point in the history
…ad in properly
  • Loading branch information
aldavigdis committed Jul 10, 2024
1 parent 3c2e89f commit ad487ed
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/Import/ProductVariations.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,19 +352,24 @@ public static function parse_variations_json( $variation_json ): array {
$variations = array();

foreach ( $variation_json as $vj ) {
$variation = array();
$code = $vj->CODE;
$description = $vj->DESCRIPTION;
$attribute_1 = $vj->SUBGROUP1;
$attribute_2 = $vj->SUBGROUP2;

$variations[ $code ] = (object) array(
$variations[ $code ] = array(
'code' => $code,
'description' => $description,
'attributes' => array(
$attribute_1 => self::get_attribute( $attribute_1 ),
$attribute_2 => self::get_attribute( $attribute_2 ),
),
);

if ( property_exists( $vj, 'SUBGROUP1' ) ) {
$variation['attributes'][ $vj->SUBGROUP1 ] = self::get_attribute( $vj->SUBGROUP1 );
}

if ( property_exists( $vj, 'SUBGROUP2' ) ) {
$variation['attributes'][ $vj->SUBGROUP2 ] = self::get_attribute( $vj->SUBGROUP2 );
}

$variations[ $code ] = (object) $variation;
}

return $variations;
Expand Down

0 comments on commit ad487ed

Please sign in to comment.