I have a problem updating the special price dates of a simple product. I've tried 2 versions of code, but without results. In both cases the special price will be update, but no affect to the start and end dates.
Version 1
$set_product = $objectManager->create('Magento\Catalog\Model\Product')->load($idSimpleProduct);
$set_product->setSpecialPrice(120.00); // this work
$set_product->setSpecialFromDate('1-1-2018'); //also tried with d/m/Y, m/d/Y, Y-m-d
$set_product->setSpecialToDate('2-2-2018');
$set_product->getResource()->saveAttribute($set_product, 'special_price');
$set_product->getResource()->saveAttribute($set_product, 'special_from_date');
$set_product->getResource()->saveAttribute($set_product, 'special_to_date');
$set_product->save();
Version 2
$set_product = $objectManager->create('Magento\Catalog\Model\Product')->load($idSimpleProduct);
$set_product->setCustomAttributes(array(
'special_from_date' => date("m-d-Y", strtotime($promoFromDate)),
'special_to_date' => date("m-d-Y", strtotime($promoToDate)),
'special_price' => $promoPrice
)
);
$set_product->save();
Where I wrong? Thanks in advance