VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: Honza on January 17, 2014, 11:55:10 AM

Title: st42_download bug report
Post by: Honza on January 17, 2014, 11:55:10 AM
Hi guys,

if anyone experiences error like this:

Warning: Invalid argument supplied for foreach() in /blah/blah/plugins/vmcustom/st42_download/st42_download.php on line 416

here is a solution which worked for me (file: /plugins/vmcustom/st42_download/st42_download.php):


...
$mediaIds = array();

/*
* HACK | Jan Linhart | for some products, the product model returns cached version of
* the product which doesn't have customfieldsCart loaded. Customer then doesn't see
* download link but "Warning: Invalid argument supplied for foreach() ..." instead.
* This hack tries to load it once more.
*/
if(!$product->customfieldsCart)
{
$customfieldModel = VmModel::getModel ('Customfields');
$product->customfieldsCart = $customfieldModel->getProductCustomsFieldCart ($product);
}
/*
* HACK end | Jan Linhart
*/

foreach ($product->customfieldsCart as $customCart) {
...


It would be nice to solve the problem at the plugin itself. It took me ages to find the problem. The solution isn't the best one, but it's the one which doesn't hack the VM files.