Welcome, Guest
Username: Password: Remember me
Use this Category for your support questions about Virtuemart Template - FashionMart (SKU# FLEX-00008)

TOPIC: Latest Products - Number of days to display

Latest Products - Number of days to display 8 years 5 months ago #3891

We have set this "Latest Products" to 9 days, but it doesn't seem to work. The banner "new" over the product image is displayed once, and that's all.

The "Featured" and "Sale" banners on the product images are displayed as the should.

Any ideas as to why the Latest/New products doesn't display with the banner on the images?

:)
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #3905

How do you mean "displayed once" ? -

in which view are you talking about -

it is soooo much easier with urls etc

if category view the code is around line 217

templates/your_template/html/com_virtuemart/category/default.php

there you can set how long ..
Last Edit: 8 years 5 months ago by John.
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #3914

Here you see the products which are on sale:
www.kollevold.no/tilbudsvarer
(The images have the banner on them.)

Here, the first product (Strips-feste, medium) is added today, and there is no "new" banner on the image:
www.kollevold.no/festemateriell/stripsfester

My colleague saw the banner once, and after reloading the page, the banner was gone.
And as I clicked to view the category, there was no "new" banner on the product image.

Sure I can go edit the file if that does it, but if the shop owner decides to change the number of days, he doesn't have a clue as to how to edit the files...
I thought it was supposed to be set in the configuration of VM?

I'll try to edit the file... and let you know how it turns out..

Thanks for the tip.

:)
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #3915

but the standard code is 1 week .. echo out what $product->created_on ($createddate) is ...
I can't see any reason why it wouldn't work . it's simple code..

and why do the www.kollevold.no/tilbudsvarer have banners??
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #3916

The banners "Nedsatt" means "on sale"... :)

Do you mean this cod:
<?php
						// CHECK IF THE PRODUCT IS NEW OR OLD. IF THE PRODUCT WAS CREATED LESS THAN 1 WEEK AGO, IT WILL HAVE "NEW" BADGE.
						$createddate = strtotime(($product->created_on) . " +1 week");  // +1 week can anything you want:  +2 week, +1 month, +24 hour   so on..
 

It says the "new" bannes should be on the product for a week.... In our configuration we have 9 days. So either way, the "new" bannes should be visible.... :/
Last Edit: 8 years 5 months ago by John.
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #3924

exactly - so what is your $createddate value? That is the only variable!
Works on everyone elses sites and on my test sites...
 
          <?php
						// CHECK IF THE PRODUCT IS NEW OR OLD. IF THE PRODUCT WAS CREATED LESS THAN 1 WEEK AGO, IT WILL HAVE "NEW" BADGE.
						$createddate = strtotime(($product->created_on) . " +1 week");  // +1 week can anything you want:  +2 week, +1 month, +24 hour   so on..
 
print 'Debug Line '.__LINE__.' $createddate <pre>'; print_r ($createddate); print "</pre><br />\n";
 
 
 
Last Edit: 8 years 5 months ago by John.
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #3933

Create date is 2013-04-03 (april 3rd)....
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #3951

but you should be getting numbers like in the screen shot
Attachments:
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #3955

Like this?

Attachment debug-1.jpg not found



Attachment debug-2.jpg not found

Last Edit: 8 years 5 months ago by Christin Larsen.
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #3956

And now....I translated the date and got some strange date:

Attachment date.jpg not found



That got me thinking:

I added a new product:

Attachment debug-3.jpg not found



Then saved the product again (made no changes):

Attachment debug-4.jpg not found



And there.... it changed the created date from the right one to the strange one.....

Have you heard of this problem before??

What in the world is wrong here?

:(
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #3965

when you look directly in your database what is happening to the timestamp when you resave?
this doesn't happen on our server - it also isn't a PureMart problem as it's doing what it's doing correctly..

also how come your $todays are identical to your $createddate - check your print code that your printing the correct var..

Cheers
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #3968

Now I've corrected the print code.. :)


Attachment debug-5_2013-04-05.jpg not found




I don't see what goes on directly in the database, since my software only displays the first thousand products... and we have over 8000... :/
In that case I need to have a print file or something... (my husband is the one doing that, and he's not available right now...)

I figured this isn't a template problem, so I have posted the subject in two VM forums as well. :)

But thanks for pointing me in the right direction... :)
Last Edit: 8 years 5 months ago by Christin Larsen.
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #3971

Certainly strange -

you can see what's in your DB by using phpmyadmin (hopefully u have cPanel hosting) and just search by a product id or whatever...

You basically want to see what happens when you resave the product to the jos_virtuemart_products table, created_on field

cos it seems it's being set to some bizarre time in the past..

u can try printing out

print 'Debug Line '.__LINE__.' $product->created_on <pre>'; print_r ($product->created_on); print "</pre><br />\n";

to see what it is



you can also print out
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #4009

I postet this problem at
forum.virtuemart.net/index.php?topic=114543.new;topicseen#new
and kkmediaproduction (Global Moderator and Jr. Member) says:

"In default vm view files there are no $today or $createdday variable. Also the default vm core does not use UNIX timestamp.

So it seems the problem must be in your template (FE)...Maybe your template use his own method to display latest products. Your DB image shows the right dates."

Does the FashionMart template really add new variables in the product table?

I'm kind of lost at this... I thought this was a problem with admin of VM..... not the template...
:/
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #4022

I did some checking of the database:

CREATE TABLE
(...)
`created_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` int(11) NOT NULL DEFAULT '0',
`modified_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified_by` int(11) NOT NULL DEFAULT '0',
(...)


I have taken a snapshot of the product table after the first save of the new product, and then again after the second save.
Nothing changes exept the modifying date/time:

INSERT INTO
(`virtuemart_product_id`,`product_s_desc`,`product_desc`,`product_name`,`metadesc`,`metakey`,`customtitle`,`slug`)

After first save:
(10356,'','','test9','','','','test9'),

After second save:
(10356,'','','test9','','','','test9'),

INSERT INTO:
(`pordering`,`virtuemart_product_id`,`virtuemart_vendor_id`,`product_parent_id`,`product_sku`,`product_weight`,
`product_weight_uom`,`product_length`,`product_width`,`product_height`,`product_lwh_uom`,`product_url`,
`product_in_stock`,`product_ordered`,`low_stock_notification`,`product_available_date`,`product_availability`,
`product_special`,`product_sales`,`product_unit`,`product_packaging`,`product_params`,`hits`,`intnotes`,
`metarobot`,`metaauthor`,`layout`,`published`,`created_on`,`created_by`,`modified_on`,`modified_by`,
`locked_on`,`locked_by`)

After first save:
(0,10356,1,0,'1234567','0.0000','KG','0.0000','0.0000','0.0000','CM','',0,0,0,'2013-04-07 00:00:00','',0,0,'KG','0.0000','min_order_level=\"\"|max_order_level=\"\"|step_order_level=\"\"|product_box=\"\"|',NULL,
'','','','0',1,'2013-04-07 08:11:02',314,'2013-04-07 08:11:02',314,'0000-00-00 00:00:00',0);

After second save:
(0,10356,1,0,'1234567','0.0000','KG','0.0000','0.0000','0.0000','CM','',0,0,0,'2013-04-07 00:00:00','',0,0,'KG','0.0000','min_order_level=\"\"|max_order_level=\"\"|step_order_level=\"\"|product_box=\"\"|',NULL,
'','','','0',1,'2013-04-07 08:11:02',314,'2013-04-07 08:11:51',314,'0000-00-00 00:00:00',0);

Then I inserted the debug lines:

Attachment debug-4_2013-04-07.jpg not found



And two different dates were displayed...

Was this information helpful in this case?

:)
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #4028

1. your reply from VM forum is rubbish - he obviously didn't understand what you asked

in our template all we do is take the $product->created_on (the field created_on), convert it to a timestamp, add 1 week to it (or what ever is set there) , compare it to todays date -> if it's greater then show the new image

in your 2 db examples your two field created_on are identical -> '2013-04-07 08:11:02'

After first save:
(0,10356,1,0,'1234567','0.0000','KG','0.0000','0.0000','0.0000','CM','',0,0,0,'2013-04-07 00:00:00','',0,0,'KG','0.0000','min_order_level=\"\"|max_order_level=\"\"|step_order_level=\"\"|product_box=\"\"|',NULL,
'','','','0',1,'2013-04-07 08:11:02',314,'2013-04-07 08:11:02',314,'0000-00-00 00:00:00',0);

After second save:
(0,10356,1,0,'1234567','0.0000','KG','0.0000','0.0000','0.0000','CM','',0,0,0,'2013-04-07 00:00:00','',0,0,'KG','0.0000','min_order_level=\"\"|max_order_level=\"\"|step_order_level=\"\"|product_box=\"\"|',NULL,
'','','','0',1,'2013-04-07 08:11:02',314,'2013-04-07 08:11:51',314,'0000-00-00 00:00:00',0);

but your second screen shot shows it as
$product->created => 0000-00-00 00:00:00

that explains why the new image doesn't show ..

Congrats - think you have uncovered a VM bug.. I tried this here and the $product object really does return 0000-00-00 00:00:00 as the $product->created_on after the first save even though in the DB it's fine - see screenshot

will try and look further were this is occuring.. stay tuned..
Attachments:
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #4031

Ok - yes - it's a bug in the VM core files..

I don't know if you want to hack a core file until they fix it?

the problem is in administrator/components/com_virtuemart/models/product.php line ~ 759

just before this the $product object is showing

Debug Line product.php 759 $product->created_on => 2012-10-22 10:36:01

the product price model -
they get a product price array back

e.g.

Debug Line product.php 760 $product->prices[0]

Array
(
[virtuemart_product_price_id] => 1
[virtuemart_product_id] => 5
[virtuemart_shoppergroup_id] =>
[product_price] => 24.99000
[override] => 0
[product_override_price] => 0.00000
[product_tax_id] =>
[product_discount_id] =>
[product_currency] => 144
[product_price_publish_up] => 0000-00-00 00:00:00
[product_price_publish_down] => 0000-00-00 00:00:00
[price_quantity_start] => 0
[price_quantity_end] => 0
[created_on] => 0000-00-00 00:00:00
[created_by] => 0
[modified_on] => 0000-00-00 00:00:00
[modified_by] => 0
[locked_on] => 0000-00-00 00:00:00
[locked_by] => 0
)

as you can see it has an element created_on which is 0000-00-00 00:00:00

this array is then merged with the $product object

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

and the created_on is overwritten

now the $product object is

Debug Line product.php 765 $product->created_on => 0000-00-00 00:00:00

there's the problem

##########################

to fix

file administrator/components/com_virtuemart/models/product.php find around line 759
 
$db->setQuery($q);
		$product->prices = $db->loadAssocList();
		$err = $db->getErrorMsg();
		if(!empty($err)){
			vmError('getProductSingle '.$err);
		} else {
			//vmdebug('getProductSingle getPrice query',$q);
		//	vmdebug('getProductSingle ',$quantity);
			//vmTrace('hmpf');
		}
 
 
		if(count($product->prices)===1){
			$product = (object)array_merge ((array)$product, (array)$product->prices[0]);

add between these lines

unset($product->prices[0]);//GJC fix for created_on

so it looks like
 
$db->setQuery($q);
		$product->prices = $db->loadAssocList();
		$err = $db->getErrorMsg();
		if(!empty($err)){
			vmError('getProductSingle '.$err);
		} else {
			//vmdebug('getProductSingle getPrice query',$q);
		//	vmdebug('getProductSingle ',$quantity);
			//vmTrace('hmpf');
		}
            unset($product->prices[0]['created_on']);//GJC fix for created_on
 
		if(count($product->prices)===1){
			$product = (object)array_merge ((array)$product, (array)$product->prices[0]);
 

the $product object will now be

Debug Line product.php 759 $product->created_on => 2012-10-22 10:36:01
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #4037

My administrator/components/com_virtuemart/models/product.php lokks a little different...:
(...)
		$db->setQuery($q);
		$prices = $db->loadAssocList();
		$err = $db->getErrorMsg();
		if(!empty($err)){
			vmError('getProductSingle '.$err);
		} else {
			//vmdebug('getProductSingle getPrice query',$q);
		}
		return $prices;
	}
 
	public function getProductPrices(&$product,$quantity,$virtuemart_shoppergroup_ids,$front,$loop=false)
{
(...)

I'm not an expert in php, so I really don't take the chance of changing anything before you check out my code.. ;)

But I'm really greatful if this works out... :)
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #4038

Hmm - that's miles out..

your looking for
 
if(count($product->prices)===1){
			$product = (object)array_merge ((array)$product, (array)$product->prices[0]);
 

immediately before that you want to add
unset($product->prices[0]['created_on']);//GJC fix for created_on 

this deletes the prices created_on (this is whats overwriting the product created_on) before merging the product and prices arrays

so will look like
 
	unset($product->prices[0]['created_on']);//GJC fix for created_on 
 
		if(count($product->prices)===1){
			$product = (object)array_merge ((array)$product, (array)$product->prices[0]);
 
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #4039

So this is what that part looks like:
if(count($product->prices)===1){
			unset($product->prices[0]['virtuemart_product_id']);
			$product = (object)array_merge ((array)$product, (array)$product->prices[0]);
		} else if ( $front and count($product->prices)>1 ) {
			foreach($product->prices as $price){
 
				if(empty($price['virtuemart_shoppergroup_id'])){
					if(empty($emptySpgrpPrice))$emptySpgrpPrice = $price;
				} else if(in_array($price['virtuemart_shoppergroup_id'],$virtuemart_shoppergroup_ids)){
					$spgrpPrice = $price;
					break;
				}
			}
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #4040

Now here's a funny thing - just checked VM2.0.20b and look what I found .. obviously this has caused problems before (not created_on but overwriting the same named info..

administrator/components/com_virtuemart/models/product.php line ~ 798
if(count($product->prices)===1){
			unset($product->prices[0]['virtuemart_product_id']);
			$product = (object)array_merge ((array)$product, (array)$product->prices[0]);
 

so just add
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]);
 
 
Last Edit: 8 years 5 months ago by John.
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #4041

Oh! We like you very much!! ;)

Hurray!

Attachment jippy-jippy-jippy.jpg not found



Thank you - thank you - thank you!!!

Do you report this bug to the VM people? You fixed it... !

I'll give you credit in the other forum as well... :D
The administrator has disabled public write access.

Latest Products - Number of days to display 8 years 5 months ago #4044

he he - thank you - yes - that's me on the VM forum (I saw your post) but he just won't believe me.. he he

Hopefully they will update on the next release..

Cheers
The administrator has disabled public write access.
Time to create page: 0.466 seconds

MaterialMart

for Virtuemart 3

Google's Material Design has finally arrived to Virtuemart

Virtumart Template - MaterialMart Virtumart Template - CleanMart Virtumart Template - CleanMart Virtumart Template - CleanMart

Fully responsive!

Buy Now   |   Live Demo