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

unpublished categories causing error in 2.0.18a product.php

Started by dzséti, January 28, 2013, 09:10:22 AM

Previous topic - Next topic

dzséti

I am upgrading to 2.0.18a and have discovered what I think is a bug in admin.../comp.../com_virtuemart/models/product.php

I have unpublished categories for my VAT rules and while these categories remain unpublished I get the error in the category layout: "Notice: Undefined offset: 0 in /home/artgecco/public_html/test/administrator/components/com_virtuemart/models/product.php on line 899" - this is the line reading: $canonCatLink = $categories[0];

If I publish the category then the problem goes away. Here is the code:

// Load the categories the product is in
//$product->categories = $this->getProductCategories ($this->_id, $front);
$product->categories = $this->getProductCategories ($this->_id, FALSE); //We need also the unpublished categories, else the calculation rules do not work

$product->virtuemart_category_id = 0;
if ($front) {

$canonCatLink = 0;
if (!empty($product->categories) and is_array ($product->categories) and count($product->categories)>1){

if (!class_exists ('shopFunctionsF')) {
require(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php');
}
if (!empty($product->categories) and is_array ($product->categories)) {
$categories = $this->getProductCategories ($this->_id, TRUE);   //only published
if(!is_array($categories)) $categories = (array)$categories;
$canonCatLink = $categories[0];
}


How should I change the code to get this error removed? Any ideas?


Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

dzséti

Tried the product model from the download, but I still get the error when I dsiable a (VAT) product category that is used by certain products.

(At first I thought that it might be something to do with the CherryPicker extension that use - I used their replacement product.php for 2.0.18a http://www.galt.md/faqfiles/vm2/product_php/pt_vm2018a.zip - but replacing it with the most recent file from the core, did not solve anything!)

Any other ideas, Milbo? You can have access to the site, if you need to!