我们有一个报价模块,它将提交报价请求,然后重定向到某个页面。我们想回到产品页面,但在尝试了一些事情之后,它仍然无法正常工作。
下面的代码显示了报价的处理器,最后显示:$this->_redirect('Quotation/Quote/List/');
我在试图获取网址方面尝试了一些想法,但到目前为止还没有任何工作。
在处理产品网址时,我需要添加什么才能获取产品网址,然后重定向到该网页而不是报价/报价/列表页面?
/**
* 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/');
}
答案 0 :(得分:4)
而不是。_redirect()
使用_redirectReferer()
看起来_redirect()
与getUrl()
的作用相同(事实上,它按原样使用)。
$this->_redirect('catalog/product/view', array(
'id'=>$product->getId(),
'_use_rewrite'=>true
));
注意:由于可以识别产品的方式,这将重定向到URL中没有类别的页面。如果您知道从中选择/提交产品的类别ID,请将其作为category
包含在数组中。