Jump to content

Change Product Add Date to affect New


Recommended Posts

Few years ago @David Eschmeyer and @studioneko write a code to change product add date.

But unfortunately its for prestashop 1.6 but i have 1.7.8

Is it possible to use it in Prestashop 1.7.8?

 

Quote

 

works in 1.6.1.x

Add it to line 132 (1.6.1.3) (after hard return) of: admin folder\themes\default\template\controllers\products\informations.tlp

 

{if $product->date_add}
<div class="form-group">
<label class="control-label col-lg-3"></td>
<span class="label-tooltip" data-toggle="tooltip"
                title="{l s='Change date for "product new from".'}">
{$bullet_common_field} {l s='New from'}
</span>
</label>
<div class="col-lg-3">
<input type="text" id="date_add" class="datepicker" name="date_add" value="{$product->date_add|escape:html:'UTF-8'}" />
</div>
</div>
{/if}

 

Edited by MariuszS (see edit history)
Link to comment
Share on other sites

I want the product for which I have changed the description, name, etc. to be displayed as "new product".
However, I don't want to do it manually every time in the database via PhpMyAdmin etc.
I would like to be able to do this through the store's administration panel. Preferably when editing a product.
I thought that the code I mentioned at the beginning could be easily adapted to Prestashop 1.7

Link to comment
Share on other sites

Hi override Product.php function update().

/* added */
$this->date_add = date('Y-m-d H:i:s');

 

Or in your module add hook:

public function hookActionObjectProductUpdateAfter($params)
{
    $db = Db::getInstance();
    $db->execute("UPDATE "._DB_PREFIX_."product SET date_add = '".date('Y-m-d H:i:s')."' WHERE id_product = ".$params['object']->id);
    $db->execute("UPDATE "._DB_PREFIX_."product_shop SET date_add = '".date('Y-m-d H:i:s')."' WHERE id_product = ".$params['object']->id);
}

 

Edited by ps8moduly.cz (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...