How Can I Clear This Every 24Hrs?

How can i clear this product view counter field every 24hrs?

{"SELECT viewed FROM ?:product_popularity WHERE product_id = ?i"|db_get_field:$product.product_id}

Use a cron job

Yeah can you point me on how? thanks

Depends on your database, but you should invoke something along the lines of

$ mysql -u[database_user] -p"[database_password]" [database] -e "UPDATE [table_prefix]product_popularity SET viewed = '0' WHERE 1"

Where everything between `[]` should be replaced with your according variables.

Why don't you want to track product views?

product views are done in the frontend/products.php controller.

Suggest you use the hook 'update_product_notifications_pre' to alter the data that is updated if you want to disable the 'viewed' tracking.

I can't find the template code you are referring to in the standard release.

If you need help utilizing the hook, feel free to contact me via the 'get a quote' link in my signature.

If you truly want to do this hourly because you want to see views/hr, suggest you also utilize that hook and possibly extend the functionality to capture views/hr rather than zapping the total views. But note that you will then need code to visualize the data like a line graph or bar graph and a way to select the period you want to view.

Yes, I want to show the views per hour on the product detailed page to everyone except the seller of that item, the seller show see the entire views

Yes, I want to show the views per hour on the product detailed page to everyone except the seller of that item, the seller show see the entire views

Then you will have to track every product view with a timestamp and clear those added with a certain timestamp every hour.

Then you will have to track every product view with a timestamp and clear those added with a certain timestamp every hour.

How can i do this, sound like a good solution

Can i clone this {"SELECT viewed FROM ?:product_popularity WHERE product_id = ?i"|db_get_field:$product.product_id} and clear the clone and leave this one

i tried changing viewed to prd_viewed but it didn't work;

{"SELECT viewed FROM ?:product_popularity WHERE product_id = ?i"|db_get_field:$product.product_id}

Why are you using template code? Did you create the column named 'prd_viewed'?

Given the number of your questions across several topics, suggest you hire a developer to work with you to accomplish your needs.

this is what i did, i didn't create the column i'm trying to clone the existing column can you help me with creating the column?

I know i'm almost there, just a little push..

function fn_prd_viewed($product_id){
$prd_view_old = db_get_field("SELECT prd_views from ?:products WHERE product_id = ?i",$product_id);
$data = array(
'prd_views' => $prd_view_old+1,
);
//to set prd_views zero (I'm not sure it's correct)
db_query("UPDATE ?:products SET ?u WHERE product_id = ?i", "0", $product_id);
}

this is what i did, i didn't create the column i'm trying to clone the existing column can you help me with creating the column?

I know i'm almost there, just a little push..

You can create new columns in few click in phpmyadmin. But it is still not clear for me what are you trying to do, sorry

You can create new columns in few click in phpmyadmin. But it is still not clear for me what are you trying to do, sorry

This snippet db_get_field("SELECT viewed from ?:products WHERE product_id = ?i",$product_id); will get the product views from the column viewed in database, i want to clone this snippet to have a second product views i can clear without clearing the main product views on viewed column.

I need to know how to:

Create column for prd_views to act like column viewed

Update the count of prd_views to zero using php

here is what i have tried

db_get_field("UPDATE prd_views from ?:products WHERE product_id = ?i",$product_id, "0"); <-not sure if this will set count to zero->

This snippet db_get_field("SELECT viewed from ?:products WHERE product_id = ?i",$product_id); will get the product views from the column viewed in database, i want to clone this snippet to have a second product views i can clear without clearing the main product views on viewed column.

I need to know how to:

Create column for prd_views to act like column viewed

Update the count of prd_views to zero using php

here is what i have tried

db_get_field("UPDATE prd_views from ?:products WHERE product_id = ?i",$product_id, "0"); <-not sure if this will set count to zero->

You do not appear to have any SQL or PHP experience. I would again suggest that you hire a developer to help you. When you hire a developer, you are paying for time spent as well as some guarantee that your needs will be met and that things will be done in a manner that will survive future updates (normally).

You can create new columns in few click in phpmyadmin. But it is still not clear for me what are you trying to do, sorry

I believe he thinks that if he captures data over the period of one hour that he will get views/hr. But as you know, you will get views from last time it was zeroed.

I believe he thinks that if he captures data over the period of one hour that he will get views/hr. But as you know, you will get views from last time it was zeroed.

He should create a temporary / memory table and then store store something by `product_id | datetime`, and then just select the count where date time is larger than now() - 1 hour, and have a cron job periodically clear the table.

You do not appear to have any SQL or PHP experience. I would again suggest that you hire a developer to help you. When you hire a developer, you are paying for time spent as well as some guarantee that your needs will be met and that things will be done in a manner that will survive future updates (normally).

I agree. He should just hire a developer. Its easier, and more convenient. Besides that, you will not end up accidentally causing any vulnerabilities or breaking your store with faulty SQL.

You can create new columns in few click in phpmyadmin. But it is still not clear for me what are you trying to do, sorry

eComs can you please give me the php snippet that can get the product views?

He should create a temporary / memory table and then store store something by `product_id | datetime`, and then just select the count where date time is larger than now() - 1 hour, and have a cron job periodically clear the table.

I agree. He should just hire a developer. Its easier, and more convenient. Besides that, you will not end up accidentally causing any vulnerabilities or breaking your store with faulty SQL.

You have great ideas but all in theory, if you can show few snippets i can work from there, I don't have money to hire a developer yet

eComs can you please give me the php snippet that can get the product views?

Use code form post #1. But I agree with other answers here. Hire a developer to avoid problems with upgrades and other possible errors