Set Special Price Programmatically In Magento

前端 未结 2 1753
再見小時候
再見小時候 2020-12-24 15:04

I am trying to write a script that will set a special price on a product with a start and an end date. When I run my script it does successfully set the special price, but t

相关标签:
2条回答
  • 2020-12-24 16:00

    I have just tried your code on my catalog and it worked with a little adjustement.

    You should pay attention to the loaded store; it is not allowed to update certain product fields if the ADMIN store is not the currently loaded (Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);).

    <?php
    
    require_once('app/Mage.php');
    
    Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
    
    ...
    
    $product->save();
    ?>
    
    0 讨论(0)
  • 2020-12-24 16:01

    This is just a guess but have you tried passing a timestamp like from time() and leaving out the setSpecialFromDateIsFormated(true)? That should cause the backend model to reformat it appropriately for you.

    0 讨论(0)
提交回复
热议问题