Skip to content

Commit

Permalink
add images to product variation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sami Kerboute committed Nov 20, 2020
1 parent 438c2c8 commit 28599bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Feed/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ function (
}
}

if ( ! empty( $sf_product->get_images() ) ) {
$images = $sf_product->get_images();
if ( ! empty( $images ) ) {
$product->setAdditionalImages( $sf_product->get_images() );
}

Expand Down Expand Up @@ -201,6 +202,10 @@ function (
$variation
->setMainImage( $sf_product_variation['image_main'] );
}
$variation_images = $sf_product->get_variation_images();
if ( ! empty( $variation_images ) ) {
$variation->setAdditionalImages( $variation_images );
}
}
}
);
Expand Down
9 changes: 8 additions & 1 deletion src/Products/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,13 @@ function ( $img ) {
);
}

/**
* @return array
*/
public function get_variation_images() {
return apply_filters( 'shopping_feed_variation_images', [], $this->product );
}

public function has_variations() {
return ! empty( $this->get_variations() );
}
Expand Down Expand Up @@ -358,6 +365,6 @@ public function get_variation_attributes( $variation ) {
* Field : ['name'=>'', 'value'=>'']
*/
public function get_extra_fields() {
return apply_filters( 'shopping_feed_extra_variation_attributes', [], $this->product );
return apply_filters( 'shopping_feed_extra_fields', [], $this->product );
}
}

0 comments on commit 28599bf

Please sign in to comment.