News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

st42_download bug report

Started by Honza, January 17, 2014, 11:55:10 AM

Previous topic - Next topic

Honza

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.