Magento:更新产品价格的前端文本字段?

时间:2013-04-30 15:37:30

标签: magento frontend

我不知道如何做到这一点,这确实需要添加到具有普通产品的工作商店,我可以制作一个新模板来执行此操作。

1 个答案:

答案 0 :(得分:0)

使用控制器创建自定义magento模块

然后在SavepriceController.php中创建一个保存操作

public function saveAction(){
    $websites = Mage::app()->getWebsites();

    $product_id = $this->getRequest()->getParam('product_id');
    // need to validate price here
    $price = $this->getRequest()->getParam('price');

    $product = Mage::getModel('catalog/product')->load($product_id)
    if($product->getId()){
        $product->setPrice($price)->save();
    }
}

然后在前端页面添加文本字段

 <form action='http://site.com/modulename/Saveprice/save' method='post'>
      <input type='hidden' name='product_id' value='add product id here' />
      <input type='text' name='price' />
      <input type='submit' value='submit' />
 </form>