代码之家  ›  专栏  ›  技术社区  ›  Knowledge Craving

在Magento为产品设定特别价格日期

  •  3
  • Knowledge Craving  · 技术社区  · 14 年前

    我在magento中添加了一个简单的产品,我想在其中设置以下内容,以及others:-

    1. 特价
    2. 特价起始日期

    1. 设置数据()
    2. 设置SpecialFromDate()

    但上述两种方法都不起作用。
    同样的情况也适用于#3分。

    如果有人能帮上忙,我真的很感激。

    2 回复  |  直到 14 年前
        1
  •  4
  •   Knowledge Craving    14 年前

    经过一天的浪费,我终于成功了。使用下面的代码work:-

    <?php
    // Both the Start & End Dates must be in MySQL DB Format
    $startDate = '2010-06-30';
    $endDate = '2010-09-30';
    
    // Creates the Product object, whose Special Dates are going to be changed
    $product = new Mage_Catalog_Model_Product();
    $product->load(YOUR_REQUIRED_PRODUCT_ID);
    
    // Sets the Start Date
    $product->setSpecialFromDate($startDate);
    $product->setSpecialFromDateIsFormated(true);
    
    // Sets the End Date
    $product->setSpecialToDate($endDate);
    $product->setSpecialToDateIsFormated(true);
    ?>
    

        2
  •  0
  •   Nic    14 年前