Php 从产品目录页面重定向到产品详细信息页面,而不是将产品添加到购物车
我想从产品目录页面重定向到产品详细信息页面,而不是将产品添加到购物车 下面是代码片段Php 从产品目录页面重定向到产品详细信息页面,而不是将产品添加到购物车,php,magento,redirect,Php,Magento,Redirect,我想从产品目录页面重定向到产品详细信息页面,而不是将产品添加到购物车 下面是代码片段 public static function getListing($_product, $productObj, $isgrid, $isa = false) { $_typeId = self::getAttributeCodeForId($_product->getId(), 'type_id'); $_isReservation = self::getAttributeCodeF
public static function getListing($_product, $productObj, $isgrid, $isa = false)
{
$_typeId = self::getAttributeCodeForId($_product->getId(), 'type_id');
$_isReservation = self::getAttributeCodeForId($_product->getId(), 'is_reservation');
if (!self::useListButtons() || !(ITwebexperts_Payperrentals_Helper_Data::isReservationType($_product))) {
$buttonsArr = array();
if (ITwebexperts_Payperrentals_Helper_Data::isReservationType($_product)) {
if ($_isReservation == ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_RENTAL && $_typeId != ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_GROUPED) {
$addToCartTitle = Mage::helper('payperrentals')->__('Add to Queue');
} elseif ($_isReservation == ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_RENTAL && $_typeId == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_GROUPED) {
$addToCartTitle = Mage::helper('payperrentals')->__('Add All To Queue');
//check if at least one is simple and add the button addtocart
$childrensArr = $_product->getTypeInstance(true)->getAssociatedProducts($_product);
$p = 0;
$c = 0;
foreach ($childrensArr as $iChild) {
if ($iChild->getTypeId() == 'simple') { // or configurable and isReservation=disabled or bundle and isreservation=disabled
if ($c == 0) {
$buttonsArr[] = '<p><button type="button" title="' . Mage::helper('payperrentals')->__('Add to Cart') . '" class="button btn-cart" onclick="setLocation(\'' . Mage::helper('payperrentals')->getAddToCartUrl($iChild) . '\')"><span><span>' . Mage::helper('payperrentals')->__('Add to Cart') . '</span></span></button></p>';
}
$c++;
} elseif ($iChild->getIsReservation() == ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_RENTAL) {
$p++;
}
}
if ($p == 1) {
$addToCartTitle = Mage::helper('payperrentals')->__('Add to Queue');
}
if ($c > 1) {
$buttonsArr = array();
}
} else {
$addToCartTitle = Mage::helper('payperrentals')->__('Rent Now');
}
} else {
$addToCartTitle = Mage::helper('payperrentals')->__('Add To Cart');
}
$retBut = '';
if ($_isReservation == ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_RENTALANDRESERVATION) {
$retBut .= ($isgrid ? '<div class="actions-btn">' : '<p class="actions-btn">') . '<button type="button" title="' . Mage::helper('payperrentals')->__('Add to Queue') . '" class="button btn-cart1" onclick="setLocation(\'' . Mage::helper('checkout/cart')->getAddUrl($_product, array('_query' => array('options' => array('one_option' => 'no_value'), 'is_reservation' => ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_RENTAL))) . '\')"><span><span>' . Mage::helper('payperrentals')->__('Add to Queue') . '</span></span></button>
<button id="product-id-' . $_product->getId() . '" type="button" title="' . $addToCartTitle . '" class="button btn-cart" onclick="setLocation(\'' . $productObj->getAddToCartUrl($_product) . '\')"><span><span>' . Mage::helper('payperrentals')->__('Rent') . '</span></span></button>' . ($isgrid ? '</div>' : '</p>');
} elseif ($_isReservation == ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_RENTAL) {
$retBut .= ($isgrid ? '<div class="actions-btn">' : '<p class="actions-btn">') . '<button type="button" title="' . $addToCartTitle . '" class="button btn-cart1" onclick="setLocation(\'' . Mage::helper('checkout/cart')->getAddUrl($_product, array('_query' => array('options' => array('one_option' => 'no_value'), 'is_reservation' => ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_RENTAL))) . '\')"><span><span>' . $addToCartTitle . '</span></span></button>' . ($isgrid ? '</div>' : '</p>');
} else {
if (!$isa) {
$retBut .= ($isgrid ? '<div class="actions-btn">' : '<p class="actions-btn">') . '<button id="product-id-' . $_product->getId() . '" type="button" title="' . $addToCartTitle . '" class="button btn-cart" onclick="setLocation(\'' . $productObj->getAddToCartUrl($_product) . '\')"><span><span>' . $addToCartTitle . '</span></span></button>' . ($isgrid ? '</div>' : '</p>');
} else {
$retBut .= '<a id="product-id-' . $_product->getId() . '" title="' . $addToCartTitle . '" class="btn-cart" href="' . $productObj->getAddToCartUrl($_product) . '">' . $addToCartTitle . '</a>';
}
}
foreach ($buttonsArr as $but) {
if (!$isa) {
$retBut .= ($isgrid ? '</div>' : '') . $but . ($isgrid ? '</div>' : '');
}
}
$price = $productObj->getPriceHtml($_product, true);
if ($isgrid) {
if (count($buttonsArr) == 0) {
$action = '<div class="actions">';
} else {
$action = '<div class="actions1"><style> .products-grid .actions1 { position:absolute; bottom:3px; } .products-grid .actions1 button{ margin-top:2px; } </style>';
}
} else {
$action = '';
}
return array(
'buttons' => $retBut,
'pricing' => $price,
'action' => $action
);
} else {
if ($isgrid) {
$action = '<div class="actions">';
} else {
$action = '';
}
$price = $productObj->getPriceHtml($_product, true);
return array(
'buttons' => '',
'pricing' => $price,
'action' => $action
);
//get the defined periods for the product
//check if product is available for that period? using the startDateinitial
//modify view.phtml to use the rent buttons
}
}
公共静态函数getListing($\u product、$productObj、$isgrid、$isa=false)
{
$\u typeId=self::getAttributeCodeForId($\u product->getId(),'type\u id');
$\u isReservation=self::GetAttributeCodeForrid($\u product->getId(),'is_reservation');
如果(!self::useListButtons()| |!(ITwebexperts\u PayPerentals\u Helper\u Data::isReservationType($\u product))){
$buttonsArr=array();
if(ITwebexperts\u Payperrentals\u Helper\u数据::isReservationType($\产品)){
如果($\u isReservation==ITwebexperts\u PayPerentals\u Model\u Product\u isReservation::STATUS\u RENTAL&&&$\u typeId!=ITwebexperts\u PayPerentals\u Helper\u Data::Product\u TYPE\u Group){
$addToCartTitle=Mage::helper('payperrentals')->(添加到队列中);
}elseif($\u isReservation==ITwebexperts\u Payperrentals\u Model\u Product\u isReservation::STATUS\u RENTAL&&$\u typeId==ITwebexperts\u Payperrentals\u Helper\u Data::Product\u TYPE\u Group){
$addToCartTitle=Mage::helper('payperrentals')->(将所有内容添加到队列中);
//检查是否至少有一个是简单的,并添加按钮addtocart
$childrensArr=$\u product->getTypeInstance(true)->getAssociatedProducts($\u product);
$p=0;
$c=0;
foreach($childrensArr作为$iChild){
如果($iChild->getTypeId()=='simple'){//或可配置且isReservation=禁用或捆绑且isReservation=禁用
如果($c==0){
$buttonsArr[]=''.Mage::helper('payperentals')->(Add to Cart')。';
}
$c++;
}elseif($iChild->getIsReservation()==ITwebexperts\u PayPerEntals\u Model\u Product\u Isreservation::STATUS\u RENTAL){
$p++;
}
}
如果($p==1){
$addToCartTitle=Mage::helper('payperrentals')->(添加到队列中);
}
如果($c>1){
$buttonsArr=array();
}
}否则{
$addToCartTitle=Mage::helper('payperrentals')->uuu('Rent Now');
}
}否则{
$addToCartTitle=Mage::helper('payperrentals')->(添加到购物车中);
}
$retBut='';
如果($\u isReservation==ITwebexperts\u PayPerEntals\u Model\u Product\u isReservation::STATUS\u RENTALANDRESERVATION){
$retBut.=($isgrid?“”:“”)。”.Mage::helper('payperentals')->(“添加到队列”)。'
“.Mage::helper('payperentals')->(Rent')。”($isgrid?“”:“
”);
}elseif($\u isReservation==ITwebexperts\u Payperrentals\u Model\u Product\u isReservation::STATUS\u RENTAL){
$retBut.=($isgrid?“”:“”)。$addToCartTitle.($isgrid?“”:“
”);
}否则{
如果(!$isa){
$retBut.=($isgrid?“”:“”)。$addToCartTitle.($isgrid?“”:“
”);
}否则{
$retBut.='';
}
}
foreach($buttonsArr作为$but){
如果(!$isa){
$retBut.=($isgrid?'':)$but($isgrid?'':);
}
}
$price=$productObj->getPriceHtml($\产品,true);
如果($isgrid){
如果(计数($buttonsArr)==0){
$action='';
}否则{
$action='.products grid.actions1{位置:绝对;底部:3px;}.products grid.actions1按钮{边距顶部:2px;}';
}
}否则{
$action='';
}
返回数组(
“按钮”=>$retBut,
“定价”=>美元价格,
'action'=>$action
);
}否则{
如果($isgrid){
$action='';
}否则{
$action='';
}
$price=$productObj->getPriceHtml($\产品,true);
返回数组(
'按钮'=>'',
“定价”=>美元价格,
'action'=>$action
);
//获取产品的定义周期
//使用startDateinitial检查该期间是否有产品可用
//修改view.phtml以使用租金按钮
}
}
那么,有谁能告诉我这些更改的位置以及重定向到产品详细信息页面需要做哪些更改呢?如果我正确理解您的意思,我认为您应该将
getAddToCartUrl
的所有调用替换为$\u product->getUrlPath()
,谢谢您的帮助。