manipulate products array in actionPresentOrder hook in Prestashop 1.7.8.x

Viewed 50

I'm attempting to manipulate thr products array in the actionPresentOrder hook as follows:

public function hookActionPresentOrder($params)
{
    foreach ($params['presentedOrder']['products'] as &$product) {
        $product['image'] = 'test;
    }
}

However, this produces the following error:

Notice: Indirect modification of overloaded element of PrestaShop\PrestaShop\Adapter\Presenter\Order\OrderLazyArray has no effect

Any suggestions on how to modify the products array would be welcomed.

1 Answers

I found the following method worked for me: $params['presentedOrder']->offsetSet('products', $products, true);

Not sure if this is the correct approach, please correct me if it is not

Related