hello, VM is very ineffecient in handling custom fields and i would suggest to modify sublayout/customfields to prevent any sort of recursion there. the main problem is that it loads related products of related products and then possibly another related products, until your site either crashes or is very slow.
i generally do not suggest to use related products if you cannot have a dev which can fix the above issue for you.
we've got some custom systems that store related products in comma separated columns in custom tables where they get imported from external systems via sync software. then our system at vm templates load this extra information and shows the related products at another positions wherever needed.
example :
- Code: Select all
$this->alternative_products_html = '';
if (!empty($this->product->extra['alternative_products_vm'])) {
$ids = explode(',', $this->product->extra['alternative_products_vm']);
if (!empty($ids)) {
$products = $this->product_model->getProducts ($ids);
if (!class_exists ('vmCustomPlugin')) {
require(JPATH_ADMINISTRATOR.DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_virtuemart'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR . 'vmcustomplugin.php');
}
$this->product_model->addImages($products,1);
foreach ($products as $k=>$prod) {
if (empty($prod->images[0])) {
if (class_exists('VmMediaHandler')) {
$products[$k]->images[0] = new VmMediaHandler();
}
else {
if (class_exists('VmImage')) {
$products[$k]->images[0] = new VmImage();
}
}
}
$products[$k]->stock = $this->product_model->getStockIndicator($products[$k]);
}
//shopFunctionsF::sortLoadProductCustomsStockInd($products,$this->product_model);
ob_start();
require(JModuleHelper::getLayoutPath('mod_virtuemart_product_custom','default'));
$this->alternative_products_html = ob_get_clean();
}
}
1. the code above expects the comma separated list of alternative/related/etc products within:
$ids = explode(',', $this->product->extra['alternative_products_vm']);
2. dependencies: $this->product_model = VmModel::getModel('products'); (usually available in product's default template )
3. mod_virtuemart_product_custom (which is a custom mod of mod_virtuemart_product ) (renders products via sublayouts/products.php )
best regards,stan