Home » Php » php – Show product creation & last edit dates on Frontend in Magento

php – Show product creation & last edit dates on Frontend in Magento

Posted by: admin July 12, 2020 Leave a comment

Questions:

I’ve seen the two attributes in the MySQL database at table catalog_product_entity

the fields are ‘created_at’ and ‘updated_at’

How do I get them to show up on frontend?

How to&Answers:

The attributed can simply be added using the getAttributeName() function, for instance, to get created_at, just add the following php script to the phtml page:

<?php echo $_product->getCreatedAt();?>

For updated_at, use:

<?php echo $_product->getUpdatedAt();?>

Answer:

If you are showing these two things in listing page, probably they will not be displayed.
Instead use following code:

For Created

<?php echo Mage::getModel('catalog/product')->load($_product->getId())->getCreatedAt();?>

For Updated:

<?php Mage::getModel('catalog/product')->load($_product->getId())->getUpdatedAt();?>