1

I don't have a whole lot of information on why this is happening and so this is going to be a fairly straight forward question.

I have 8 products and they all direct to the product page except one. This one in particular use to direct to it's respective product page but no longer does, it takes them right to checkout with the product. If they click the image for the said product they go to the product page and then have the opportunity to click buy now and go to the cart. But on the buy page with all the products if they click the actual "buy now" button it takes them directly to the cart and bypasses the product page. i do not want that functionality, i'm not sure what happened recently but it just started happening.

The only thing i've tried is renaming the url conventions and the url redirects. Any help would be greatly appreciated. Thanks in advance.

  <script type="text/javascript">
var pr_style_sheet="http://cdn.powerreviews.com/aux/14564/859117/css/express.css";
</script>
<script type="text/javascript" src="http://cdn.powerreviews.com/repos/14564/pr/pwr/engine/js/full.js"></script>

<?php
    $_productCollection=$this->getLoadedProductCollection();
    $_helper = $this->helper('catalog/output');
?>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<?php echo $this->getToolbarHtml() ?>
<?php echo $this->getAdditionalHtml() ?>
<div class="category-products">
    <?php // List mode ?>
    <?php if($this->getMode()!='grid'): ?>
    <?php $_iterator = 0; ?>
    <ol class="products-list" id="products-list">
    <?php foreach ($_productCollection as $_product): ?>
        <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
            <?php // Product Image ?>
            <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(166); ?>" width="166" height="166" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
            <?php // Product description ?>
            <div class="product-shop">
                <div class="f-fix">
                    <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
                    <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
                    <?php if($_product->getRatingSummary()): ?>
                    <?php echo $this->getReviewsSummaryHtml($_product) ?>
                    <?php endif; ?>
                    <?php echo $this->getPriceHtml($_product, true) . '.'; ?>
                    <div class="desc std">
                        <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
                        <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
                    </div>
                    <?php if($_product->isSaleable()): ?>
                        <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>

                    <?php else: ?>
                        <?php if ($_product->getIsSalable()): ?>
                            <p class="availability in-stock"><span><?php echo $this->__('In stock') ?></span></p>
                        <?php else: ?>
                            <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                        <?php endif; ?>
                    <?php endif; ?>
                        <ul class="add-to-links">
                            <?php if ($this->helper('wishlist')->isAllow()) : ?>
                                <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
                            <?php endif; ?>
                            <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                                <li><a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
                            <?php endif; ?>
                        </ul>
                </div>
            </div>
        </li>
    <?php endforeach; ?>
    </ol>
    <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>

<?php else: ?>

<?php // Grid Mode ?>

<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount =2;// $this->getColumnCount(); ?>
<?php $i=0; foreach ($_productCollection as $_product): 

$RatingSummary=$_product->getRatingSummary();
$_product=Mage::getModel('catalog/product')->load($_product->getId());

?>
    <?php if ($i++%$_columnCount==0): ?>
    <ul class="products-grid">
    <?php endif ?>
        <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
            <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(170,280); ?>" width="170" height="280" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>


        <div class="product-info">

        <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
            <?php if($_product->getData('power_reviews')): ?>
            <?php //echo $this->getReviewsSummaryHtml($_product, 'short') ?>

        <div  style="text-align:left;">
         <div style="display:inline-block;" class="pr_snippet_category">
                    <script type="text/javascript">
                        var pr_snippet_min_reviews=0;
                        POWERREVIEWS.display.snippet(document, { pr_page_id : "<?php echo($_product->getData('pr_page_id')) ?>" });
                    </script>  
</div>
        <div>
            <?php endif; ?>




<div  class="write-a-review" style="margin-left:228px;">

            <?php if($_product->getData('power_reviews')): ?>
<p style="text-align:center;">
<?php echo($this->__('Write a review')); ?>: 




<a onclick="Mage.Cookies.set('show_reviews',1);" href="<?php echo $_product->getProductUrl() ?>"><?php echo($this->__('on product page')) ?></a>

<span class="separator desktop">|</span>






            <a href="#" 

        onclick="      

        if($('facebook-review-<?php echo $_product->getId() ?>').style.display=='block'){
                $('facebook-review-<?php echo $_product->getId() ?>').style.display='none'; 

        }
        else{
                $('facebook-review-<?php echo $_product->getId() ?>').style.display='block'; 
        }
        return false;" class="desktop"><?php echo $this->__('on Facebook') ?></a></p>

            <?php endif; ?>


<div id="facebook-review-<?php echo $_product->getId() ?>" style="display:none;">

<div class="fb-comments" data-href="<?php echo($_product->getProductUrl()) ?>" data-width="207"  data-numposts="5" data-colorscheme="light"></div>
</div>

</div>

<div class="product-info-box" >


                        <div class="short-description std">
                            <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
                        </div>


          <?php //echo $this->getPriceHtml($_product, true) ?>
<!-- ------------------------------------------------------------------------------------>
<!-- ------------------------------------------------------------------------------------>
<!-- Hack to show a different price in product page for bundles -------->
            <?php
            $hackPrice654 = '
            <div class="price-box">
                <span class="regular-price" id="product-price-654">
                    <span class="price">$77.00</span>
                </span>
            </div>
            ';

            $hackPrice669 = '
            <div class="price-box">
                <span class="regular-price" id="product-price-669">
                    <span class="price">$297.00</span>
                </span>
            </div>
            ';

            switch ($_product->getSku()) {
                case "793573106964 / 59444":
                echo $hackPrice654;
                break;

                case "040232069451 / 793573199515":
                echo $hackPrice669;
                break;

                default:
                echo $this->getPriceHtml($_product, true);
            }
            ?>
<!-- Hack to show a different price in product page for bundles  - EOF -->
<!-- ------------------------------------------------------------------------------------>
<!-- ------------------------------------------------------------------------------------>            
            <div class="actions">
                <?php if($_product->isSaleable() AND $_product->getSku() != '53970'): ?>
                    <button type="button" title="<?php echo $this->__('BUY NOW') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('BUY NOW') ?></span></span></button>
                <?php else: ?>
                    <?php if ($_product->getIsSalable()): ?>
                        <p class="availability in-stock"><span><?php echo $this->__('In stock') ?></span></p>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>
                <?php endif; ?>
                    <ul class="add-to-links">
                        <?php if ($this->helper('wishlist')->isAllow()) : ?>
                            <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
                        <?php endif; ?>
                        <?php if($_compareUrl=$this->getAddToCompareUrl($_product)&&false): ?>
                            <li><a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
                        <?php endif; ?>
                    </ul>
            <?php if($_product->getData('fb_pinterest_share')): ?>
            <ul class="desktop social-links">
             <li>
<a href="http://pinterest.com/pin/create/button/?url=<?php echo($_product->getProductUrl()) ?>&media=<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(170,280); ?>&description=<?php echo(

$_helper->productAttribute(

$_product, $_product->getName().' - '.strip_tags($_product->getShortDescription()), 'short_description'

)

); ?>" class="pin-it-button" count-layout="<?php echo(Mage::getStoreConfig('Moii_Pinterest_Config/configuration/Moii_Pinterest_Count')); ?>">Pin It</a>


             </li>
            <!--<li><a href="#"><img src="<?php echo(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)); ?>frontend/enterprise/lsc/images/facebook.png"  /></a></li>
            <li><a href="#"><img src="<?php echo(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)); ?>frontend/enterprise/lsc/images/subscribe.png"  /></a></li>  -->
            <li><div class="fb-share-button" data-href="<?php echo($_product->getProductUrl()) ?>" data-width="60" data-type="button"></div></li>
            </ul>
                        <?php endif; ?>
            </div>
</div>


        </div>
        </li>
    <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
    </ul>
    <?php endif ?>
    <?php endforeach ?>
    <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
<?php endif; ?>
</div>
<div class="toolbar-bottom">
    <?php echo $this->getToolbarHtml() ?>
</div>
<?php endif; ?>


<script type="text/javascript">
//<![CDATA[

document.observe("dom:loaded", function() { 

if ($$('.page')[0].offsetWidth==320)
{
    var product_info_size=$$('.category-products .products-grid .product-info').size();

    for (var i=0;i<product_info_size;i++ )
    {
        $$('.category-products .products-grid .product-info .product-info-box')[i].insertBefore($$('.category-products .products-grid .product-image')[i],$$('.category-products .products-grid .product-info .product-info-box .short-description.std')[i]);
    }
}

}); 

//]]>
</script>

<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>
  • I am assuming this is happening on your themes category page. In order to help you out, you will need to post your catalog/product/list.phtml from your theme. Also, if you change back to the unedited default theme, does this still happen? – kab8609 Feb 17 '15 at 20:27
  • I'll have a look at that file right now. Is there a specific function/method i should be looking at? – thismethod Feb 17 '15 at 20:32
  • We would need the whole page. There shouldn't be any functions or methods on that kind of page. Though your first step should be quickly change your theme to the unedited Magento base theme so we can tell if it is a theme issue or something else. – kab8609 Feb 17 '15 at 20:35
  • Sorry for the delay, it's been so busy today. I've added the code from the page you were asking about. Additionally, thanks for your help. – thismethod Feb 17 '15 at 23:38
2

Magento have a feature to back to last visited page after product cart and prevent to goto cart page. and it has been managed from admin.

Setting:

admin>System>Configuration>Sales>Checkout>Shopping Cart and make the value of After Adding a Product Redirect to Shopping Cart to no

enter image description here

If you will enable this setting from admin then you can easy back to product page Whenever i will be cart from product page.you want this for all time then you need customization.

In this case you need to use Magento event/Observer

Event:

checkout_cart_add_product_complete

This event provide the data of product object and cart request parameters

Mage::dispatchEvent('checkout_cart_add_product_complete',
    array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
);

Config.xml code:

<frontend>
    <events>
    <checkout_cart_add_product_complete>
             <observers>
             <packagename_modulename_observer>
                  <type>singleton</type>
                  <class>packagename_modulename/observer</class>
                  <method>addToCartComplete</method>
             </packagename_modulename_observer>
             </observers>
         </checkout_cart_add_product_complete>
     </events>
</frontend>

Observer code:

using this event you can set your return url after cart

$observer->getEvent()->getRequest()->setParam('return_url',$observer->getProduct()->getProductUrl()); this redirect to you at product page

function:

public function addToCartComplete(Varien_Event_Observer $observer) {
 $product = $observer->getEvent()->getProduct();
 $Request=$observer->getEvent()->getRequest();
 $Request->setParam('return_url',$product->getProductUrl());
}

this redirect to you at product page

  • I'll revisit this today and get back with you about the answer. Thank you for your time sir. – thismethod Feb 20 '15 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.