cancel
Showing results for 
Search instead for 
Did you mean: 

Product getSpecialToDate not showing same as advanced price setting

Product getSpecialToDate not showing same as advanced price setting

Hi community, 

 

(using Magento 2.4)

 

I have a strange output here and cannot make sense of it:

 

I have set the Special Price in admin to be $24 instead of $29 for a product.

From date: 27/05/2021

To date: 27/06/2021

 

But in front-end the "to date" is not considered.

If I output $product->getSpecialToDate() I get 27/05/2022  !! 

 

Any idea why this is happening?

The products are imported programmatically and the dates are set correctly using setSpecialToDate...  (as I can see in admin). 

But why do I get a different value when testing with getSpecialToDate() ?? 

 

thanks for any help

 

Jerome

1 REPLY 1

Re: Product getSpecialToDate not showing same as advanced price setting

Hi, 

I would love to have someone looking at this with me.

It is getting even weirder. Let me recap the actual situation:

- Price of product is $29

- Special price : $24

- Special From Date : 1/7/2021

- Special To Date : 1/7/2022

 

All this information above is imported programmatically like so (I just add the important parts):

 

...
$state->setAreaCode('adminhtml');
...
$product->setData('store_id', 1);
$product->setPrice("29.00");
$product->setSpecialPrice("24.00"); $product->setSpecialFromDate("2021-07-02"); $product->setSpecialToDate("2022-07-02"); ....

 

 

1) I can see all that set correctly in Admin

2) I can see that it is working in Front-End

3) if I change the special price in Admin it is changed in Front-End

4) if I change the from-date or to-date in Admin nothing changes in Front-End !!

 

Anybody any idea about what could have gone wrong here?

 

thanks again

Jerome