2011-06-28 56 views
1

我们有一个报价模块,将提交报价请求,然后重定向到某个页面。我们想回到产品页面,但尝试了几件事情后仍然无法使用。Magento/PHP - 重定向提交

下面的代码显示了报价的处理器,并在最后表示:$this->_redirect('Quotation/Quote/List/');

我试过一对夫妇的想法在试图获取一个URL,但没有什么工作作为尚未条款。

我需要添加什么来获取产品URL,当它处理,然后重定向到该页面而不是报价/报价/列表页面?

/** 
    * Create a quote inquiry with cart's products 
    * 
    */ 
    public function CreateRequestAction() 
    { 
     $this->loadLayout(); 
     $this->renderLayout();    
    } 

    /** 
    * Create a quote inquiry with cart's products 
    * 
    */ 
    public function CreateIndividualRequestAction() 
    { 
     $this->loadLayout(); 
     $this->renderLayout();    
    } 


    /** 
    * Post a new quote request Individual 
    * 
    */ 
    public function SendIndividualRequestAction() 
    { 
     $CustomerId = mage::Helper('customer')->getCustomer()->getId(); 

     $storeId = mage::getModel('customer/customer')->load($CustomerId)->getStoreId(); 
     $defaultValidityDuration = Mage::getStoreConfig('quotation/general/default_validity_duration', $storeId); 
     $defaultExpirationDate = time() + $defaultValidityDuration * 24 * 3600; 

     //Create new quotation 
     $NewQuotation = mage::getModel('Quotation/Quotation') 
      ->setcustomer_id($CustomerId) 
      ->setcaption($this->__('New request')) 
      ->setcreated_time(date("Y/m/d")) 
      ->setcustomer_msg($this->getRequest()->getPost('description')) 
      ->setcustomer_request(1) 
      ->setstatus(MDN_Quotation_Model_Quotation::STATUS_CUSTOMER_REQUEST) 
      ->setvalid_end_time(date('Y/m/d', $defaultExpirationDate)) 
      ->save(); 
     $NewQuotation->setincrement_id($NewQuotation->GenerateIncrementId())->save(); 

     //Add selected product 
     $product = mage::getModel('catalog/product')->load($this->getRequest()->getPost('product_id')); 
     if ($product->getId()) 
     { 
      //add product to quotation   
      $quotationItem = mage::getModel('Quotation/Quotationitem') 
       ->setquotation_id($NewQuotation->getId()) 
       ->setorder(1) 
       ->setproduct_id($product->getId()) 
       ->setqty(1) 
       ->setprice_ht($product->getPrice()) 
       ->setcaption($product->getName()) 
       ->setsku($product->getSku()) 
       ->setcost($product->getCost()) 
       ->setweight($product->getWeight()) 
       ->save();  

      //compute quotation price & weight 
      $NewQuotation->CalculateWeight(); 
      $NewQuotation->CalculateQuotationPriceHt(); 
     } 

     //Notify admin 
     $NewQuotation->NotifyCreationToAdmin(); 


     //confirm 

     $this->_redirect('Quotation/Quote/List/'); 
    } 

回答

4

代替 _redirect()使用 _redirectReferer()

看起来像_redirect()的作品与getUrl()的作品相同(实际上,它原样使用)。

$this->_redirect('catalog/product/view', array(
    'id'=>$product->getId(), 
    '_use_rewrite'=>true 
)); 

注:因为产品的方式可以被识别,这将重定向到页面的URL没有类别。如果您知道选择/提交产品的类别ID,则将其作为category包含在阵列中。

+0

不幸的是,似乎没有工作,它只是返回到报价请求页面。我们需要它返回到报价页面之前的产品页面。 –