VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: dzséti on January 28, 2013, 09:10:22 AM

Title: unpublished categories causing error in 2.0.18a product.php
Post by: dzséti on January 28, 2013, 09:10:22 AM
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?

Title: Re: unpublished categories causing error in 2.0.18a product.php
Post by: Milbo on January 29, 2013, 16:03:32 PM
I think, we fixed that in the core and it is in the svn, please download the latest product model here http://dev.virtuemart.net/projects/virtuemart/repository/show/branches/com_virtuemart2.0.14mp/administrator/components/com_virtuemart/models
Title: Re: unpublished categories causing error in 2.0.18a product.php
Post by: dzséti on February 04, 2013, 13:49:32 PM
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 (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!