Jump to content

Change Product Add Date to affect New - ness


Recommended Posts

I'm trying to set the add date for a product so that the "new" label doesn't show up in its display.

However, I don't see a place in PrestaShop Admin to change the date for when a product was added.

 

I found mySQL code in classes/Product.php (see below),

which helped me determine which database table is being used to store the date.

 

I found the table in question, and it's `p`.`product_shop`. The column in question is `date_add`.

 

By updating my product through phpMyAdmin to a date that is further back than the current date minus the {number-of-days-for-new-product // paraphrased} setting, IT WORKS!

 

I'm wondering if there is an interface through PrestaShop Admin to do this.



public function isNew()
{
$result = Db::getInstance()->executeS('
SELECT p.id_product
FROM `'._DB_PREFIX_.'product` p
'.Shop::addSqlAssociation('product', 'p').'
WHERE p.id_product = '.(int)$this->id.'
AND DATEDIFF(
product_shop.`date_add`,
DATE_SUB(
NOW(),
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
)
) > 0
');
return count($result) > 0;
}


 

Link to comment
Share on other sites

I don't think there is any other way for changing date of individual product.

If you want to turn off new label for all products set Number of days for which the product is considered 'new' in New products module to 0

Link to comment
Share on other sites

  • 1 year later...

in bo - prod information tab  (not the product list though, in product as specified)

 

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

<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" name="date_add" value="{$product->date_add|escape:html:'UTF-8'}" /></div></div>

added the smarty if statement to hide the field if new product is really being added

  • Like 1
Link to comment
Share on other sites

  • 4 months later...

oops forgot the if statements:

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" name="date_add" value="{$product->date_add|escape:html:'UTF-8'}" />
</div>
</div>
{/if}
  • Like 1
Link to comment
Share on other sites

  • 1 month later...

 

oops forgot the if statements:

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" name="date_add" value="{$product->date_add|escape:html:'UTF-8'}" />
</div>
</div>
{/if}

 

Hey David, thanks for your code :) Works like a charm on presta 1.6.x

 

Just a small addition: we added a class="datepicker" to the input to force the date picker to show. When you select only a date, without specifying a time, the database saves it with a 00:00:00 value

{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}

  • Like 2
Link to comment
Share on other sites

×
×
  • Create New...