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

Magento:更新产品价格的前端文本字段?,magento,frontend,Magento,Frontend,我不知道如何做,这确实需要添加到正常产品的工作商店中,我可以制作一个新模板来做这件事。创建一个带有控制器的自定义magento模块 然后在SavepriceController.php中创建一个保存操作 public function saveAction(){ $websites = Mage::app()->getWebsites(); $product_id = $this->getRequest()->getParam('product_id');

我不知道如何做,这确实需要添加到正常产品的工作商店中,我可以制作一个新模板来做这件事。

创建一个带有控制器的自定义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>