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.
First http://forum.virtuemart.net/index.php?topic=79799.0
Oops!
I'm using Joomla 2.5.6, VM 2.0.20b and PHP 5.4.14. I'm using template override.
Sorry
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.