Originally Posted by
simon1066
Actually, what I've done hasn't worked as it adds the '666' to all products. Back to the drawing board.
Right, you'd need to check the incoming $products_id value and possibly the $product/$categories_list/$cPath arrays to see if the current product 'qualifies' for the change.
For what I think you're trying to do:
PHP Code:
public function getProductsAttributes(string $products_id, array $product, array $categories_list, array $cPath, array $custom_fields): array
{
if (!in_array(66, $cPath)) {
return [];
}
$extension_custom_fields = ['product_type' => '666',];
return $extension_custom_fields;
}
That checks to see if categories-id 66 is present in the current product's category-tree, returning the 'product_type' override if so; otherwise, no override is supplied.
Bookmarks