[ SOLVED ] When i edit a product, creation date changes to 0000-00-00 00:00:00

Started by El_Loboo, May 11, 2013, 22:07:56 PM

Previous topic - Next topic

El_Loboo

Hi all.

I've reprogrammated productdetails.php to show two images in depending on the discount applied and if that product was created in the last month. It works fine when only must show one of them but when a product has been created recently and i apply a discount  the product creation date changes to 0000-00-00 00:00:00.

I've looking database, in virtuemart_products table and it's show date correctly. Anyone knows what could it be?

Regards.

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

El_Loboo

Oops!

I'm using Joomla 2.5.6, VM 2.0.20b and PHP 5.4.14. I'm using template override.


Sorry

El_Loboo

Finally i found a related thread about this question publish by GJC Web Design in this forum:

QuoteWhat is happening is when the two arrays are merged in function getProductPrices()

$product = (object)array_merge ((array)$product, (array)$product->prices[0]);

the #__virtuemart_product_prices.created_on overwrites it in the $product object

So every call to $products = $productModel->getProductsInCategory($categoryId); in a template returns the #__virtuemart_product_prices.created_on not the #__virtuemart_products.created_on

and in this case it is 0000-00-00 00:00:00 - in other cases may be something else but never the less the wrong created_on is being returned in the object..

All my #__virtuemart_product_prices.created_on are 0000-00-00 00:00:00 - is there even a point to having that field?

All I do is  unset($product->prices[0]['created_on']) before the array merge so the products is not overwritten..

Solution:

administrator/components/com_virtuemart/models/product.php line ~ 798

if(count($product->prices)===1){
unset($product->prices[0]['virtuemart_product_id']);
                        unset($product->prices[0]['created_on']); //GJC fix for created_on

$product = (object)array_merge ((array)$product, (array)$product->prices[0]);


I'ts looks like works fine

Thanks GJC Web Design for the solution

Regards.