Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Automatic expire (unpublish) of products? 
 
ggouweloos
Jr. Member
 
Total Posts:  2
Joined:  2008-09-11
 

For example a ticket website I would like to have products (tickets for an event) that expire after a specific date.
When defining the product I want to give in an end-date for the product.

Can Magento do that?

 
Magento Community Magento Community
Magento Community
Magento Community
 
itognet
Jr. Member
 
Total Posts:  24
Joined:  2008-08-03
 

This is something I want too.
But I want to do this:

When importing products, I will set expire date to today+4 days.
When a product does not get imported for more than 4 days. Magento unpublish it. In this way old products automatically gets unpublished.

I was thinking of, making an attribut, lets call it expiredate
- I have seen several threads about how to get new products on homepage. Maybe some of this code, can be reprogrammed to look into the expiredate and if today <= expiredate then show the product.

IF anybody else have a solution - then i all ears.

 
Magento Community Magento Community
Magento Community
Magento Community
 
itognet
Jr. Member
 
Total Posts:  24
Joined:  2008-08-03
 

--

 
Magento Community Magento Community
Magento Community
Magento Community
 
J_T_
Mentor
 
Avatar
Total Posts:  1961
Joined:  2008-08-07
London-ish, UK
 

Yes, make a new attribute ‘expirydate’ as YYYYMMDD and then run a cron, checking whether it has expired and if yes, disable the product (update status in DB). Very simple. Just need to work out which database cell holds ‘enabled/disabled’ which you can ifn dout by saving a DB dump, then switching a product off, taking another dump and see the change with a diff program like Beyond Compare.

 
Magento Community Magento Community
Magento Community
Magento Community
 
itognet
Jr. Member
 
Total Posts:  24
Joined:  2008-08-03
 

I did some research and found this:

And both columns coresponds to when I created the product, and when I updated it. - So we can use the updated_at column

And in table catalog_product_enabled_index we delete the product_id then it will not be shown on store

The sql will look somethink like this:

SELECT
`catalog_product_entity`.`sku` as sku
FROM
`catalog_product_entity`
WHERE
`catalog_product_entity`.`updated_at` < DATE_SUB(NOW(), INTERVAL 35 DAY)

This will show SKU for products not updated for last 35 days.
This SQL is intended for use in an import file, so you can change the status of these SKU.
I will suggest that you make some sort of attribute fx. expired (yes/no) and sets is_active to no and expired to no.
When you import this expired sku list, you will touch the timestamp of updated_at and therefore you have to use the expired attribute in the SQL too. I will update this later with the correct SQL line.

How do I make a cron job for this ?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top