How can i do cross sell products blocks on add to cart popup box












0















How can i display my cross sell products blocks under add to cart popup box,



my add to cart block,



<?php

class Cmsmart_AjaxCart_IndexController extends Mage_Core_Controller_Front_Action
{
public function _constructor(){
$_SERVER['REQUEST_URI'] = array_pop(explode('web.com', @$_SERVER['HTTP_REFERER']));
}

protected function _getCart()
{
return Mage::getSingleton('checkout/cart');
}

protected function _getSession()
{
return Mage::getSingleton('checkout/session');
}

protected function _updateShoppingCart()
{
try {
$cartData = $this->getRequest()->getParam('cart');
if (is_array($cartData)) {
$filter = new Zend_Filter_LocalizedToNormalized(
array('locale' => Mage::app()->getLocale()->getLocaleCode())
);
foreach ($cartData as $index => $data) {
if (isset($data['qty'])) {
$cartData[$index]['qty'] = $filter->filter(trim($data['qty']));
}
}
$cart = $this->_getCart();
if (! $cart->getCustomerSession()->getCustomer()->getId() && $cart->getQuote()->getCustomerId()) {
$cart->getQuote()->setCustomerId(null);
}

$cartData = $cart->suggestItemsQty($cartData);
$cart->updateItems($cartData)
->save();
}
$this->_getSession()->setCartWasUpdated(true);
} catch (Mage_Core_Exception $e) {
$this->_getSession()->addError(Mage::helper('core')->escapeHtml($e->getMessage()));
} catch (Exception $e) {
$this->_getSession()->addException($e, $this->__('Cannot update shopping cart.'));
Mage::logException($e);
}
}

public function indexAction(){
$delete = $this->getRequest()->getParam('delete');
$kiemtra = true;

$update = $this->getLayout()->getUpdate();
$update->addHandle('default');
$this->addActionLayoutHandles();
if(!$delete){
$product = $this->_getProductFromUrl();
$product = Mage::registry('product');
$options = $product->getProductOptionsCollection();
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($product);
$col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
//$kiemtra = (!$product->getTypeInstance(true)->hasRequiredOptions($product) || $this->getRequest()->getParam('product') || count($col) == 0);
//$kiemtra = ($product->getTypeId() == 'simple' || $this->getRequest()->getParam('product') || $delete) && !$product->getTypeInstance(true)->hasRequiredOptions($product);
$kiemtra = $delete || $this->getRequest()->getParam('product') || !$product->getTypeInstance(true)->hasRequiredOptions($product);
if($kiemtra) {
self::tryaddAction($product, $_GET);
}

Mage::dispatchEvent('catalog_controller_product_view', array('product'=>$product));
if ($this->getRequest()->getParam('options')) {
$notice = $product->getTypeInstance(true)->getSpecifyOptionMessage();
Mage::getSingleton('catalog/session')->addNotice($notice);
}
if(@$product) Mage::getSingleton('catalog/session')->setLastViewedProductId($product->getId());

if(@$product){
$update->addHandle('PRODUCT_TYPE_'.$product->getTypeId());
$update->addHandle('PRODUCT_'.$product->getId());
}
}else{
$update->addUpdate('<remove name="product.info"/>');
$kiemtra = true;
if($delete == 'all'){
self::_emptyShoppingCart();
}else{
if($delete != 'udaj') { $this->removeAction($delete); }else {
if(@$_POST['cart']) $this->_updateShoppingCart();
//foreach(@$_POST['cart'] as $k => $v){
// $this->udpateAction($k, $v);
}
}
}

$this->loadLayoutUpdates();
$this->generateLayoutXml()->generateLayoutBlocks();

$json_encode = array();
$json_encode['ajaxcart'] = '';
$json_encode['ajaxsidebar'] = '';
$json_encode['ajaxSummaryCount'] = '';
$json_encode['ajaxCountItem'] = '';
$json_encode['ajaxcartmsg'] = '';
$json_encode['ajaxcontinue'] = '';

if($kiemtra) {
// Show the message add to cart is success
if(@$product) $json_encode['ajaxcontinue'] = '
<div>
<ul class="messages ajaxcart-messages">
<li class="success-msg">
<ul>
<li><span><a title="'.@$product->getName().'" href="'.@$product->getProductUrl().'">'.@$product->getName().' </a> '.$this->__('has been added to cart').'.</span></li>






<li><button onclick="setLocation(''.Mage::getBaseUrl().'checkout/')" class="button btn-continue" title="'.$this->__('Checkout').'" type="button"><span><span>'.$this->__('Checkout').'</span></span></button>
</ul>
</li>
</ul>
</div>';

//<button class="button btn-continue closemsg" title="Continue Shopping" type="button"><span><span>Continue Shopping</span></span></button>
//<button onclick="setLocation(''.Mage::getBaseUrl().'checkout/onepage/')" class="button btn-continue" title="'.$this->__('Proceed to Checkout').'" type="button"><span><span>'.$this->__('Proceed to Checkout').'</span></span></button>

// Drop Down Cart Block
$block = $this->getLayout()->createBlock('checkout/cart_sidebar')->setBlockId('block-id-in-magento')->setTemplate('checkout/cart/sidebar.phtml');
//$this->getLayout()->getBlock('content')->append($block);
$count = Mage::helper('checkout/cart')->getSummaryCount();
if ($count == 1) {
$text = $this->__('My Cart (%s item)', $count);
} elseif ($count > 0) {
$text = $this->__('My Cart (%s items)', $count);
} else {
$text = $this->__('My Cart');
}
$json_encode['ajaxCountItem'] = $count;
$json_encode['ajaxSummaryCount'] = $text;
$json_encode['ajaxsidebar'] = str_replace('class="block block-cart"', 'id="cart-ajax-sidebar"', @$block->toHtml());

$block2 = $this->getLayout()->createBlock('checkout/cart_sidebar')
->setTemplate('cmsmart/ajaxcart/view/sidebar.phtml')
->addItemRender('simple', 'checkout/cart_item_renderer', 'cmsmart/ajaxcart/view/sidebar/default.phtml')
->addItemRender('grouped', 'checkout/cart_item_renderer', 'cmsmart/ajaxcart/view/sidebar/default.phtml')
->addItemRender('configurable', 'checkout/cart_item_renderer', 'cmsmart/ajaxcart/view/sidebar/default.phtml');

$json_encode['ajaxcart'] = @$block2->toHtml();

}else{
$json_encode['ajaxcartmsg'] = $this->getLayout()->getBlock('content')->toHtml();
}
echo json_encode($json_encode);
}

private function tryaddAction($product, $params = array()){

$cart = Mage::getModel("checkout/cart");
$cart->addProduct($product->getId(), $params);
return $cart->save();
}

private function udpateAction($itemId, $qty){
$qty = (int)$qty?(int)$qty:1;
$cartHelper = Mage::getSingleton('checkout/cart');
$cartHelper->updateItem($itemId, $qty);
//$items = $cartHelper->getCart()->getItems();
// foreach ($items as $item) {
// if ($item->getId() == $itemId) {
// $item->setQty($qty);
// }
// }
$cartHelper->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
}

private function removeAction($itemId){
try{
$cartHelper = Mage::helper('checkout/cart');
$cartHelper->getCart()->removeItem($itemId)->save();
}catch (Mage_Core_Exception $exception) {}
}

private function emptyAction(){
$cartHelper = Mage::helper('checkout/cart');
$items = $cartHelper->getCart()->getItems();
foreach ($items as $item) {
$cartHelper->getCart()->removeItem($item->getItemId());
}
$cartHelper->getCart()->save();
}

protected function _emptyShoppingCart()
{
try {
$this->_getCart()->truncate()->save();
$this->_getSession()->setCartWasUpdated(true);
} catch (Mage_Core_Exception $exception) {
$this->_getSession()->addError($exception->getMessage());
} catch (Exception $exception) {
$this->_getSession()->addException($exception, $this->__('Cannot update shopping cart.'));
}
}

public function _getProductFromUrl(){
Mage::dispatchEvent('catalog_controller_product_init_before', array('controller_action'=>$this));
$product_id = $this->getRequest()->getParam('product');
if(!$product_id):
$path = $this->getRequest()->getParam('id');
$product_id = (int) $path;

if(!$product_id){

$path[0] == "/" ? $path = substr($path, 1, strlen($path)) : $path;
$tableName = Mage::getSingleton('core/resource')->getTableName('core_url_rewrite');
$write = Mage::getSingleton('core/resource')->getConnection('core_write');

$rs = $write->query('select `product_id` from `'.$tableName.'` where `request_path` = "'.$path.'"');

if ($row = $rs->fetch() ) {
$product_id = $row['product_id'];
}
}
endif;

if (!$product_id) {
return false;
}

$product = Mage::getModel('catalog/product')
->setStoreId(Mage::app()->getStore()->getId())
->load($product_id);

if (!Mage::helper('catalog/product')->canShow($product)) {
return false;
}
if (!in_array(Mage::app()->getStore()->getWebsiteId(), $product->getWebsiteIds())) {
return false;
}

$category = null;
if ($categoryId) {
$category = Mage::getModel('catalog/category')->load($categoryId);
$product->setCategory($category);
Mage::register('current_category', $category);
}
elseif ($categoryId = Mage::getSingleton('catalog/session')->getLastVisitedCategoryId()) {
if ($product->canBeShowInCategory($categoryId)) {
$category = Mage::getModel('catalog/category')->load($categoryId);
$product->setCategory($category);
Mage::register('current_category', $category);
}
}
Mage::register('current_product', $product);
Mage::register('product', $product);

try {
Mage::dispatchEvent('catalog_controller_product_init', array('product'=>$product));
Mage::dispatchEvent('catalog_controller_product_init_after', array('product'=>$product, 'controller_action' => $this));
} catch (Mage_Core_Exception $e) {
Mage::logException($e);
return false;
}

return $product;
}


}


my cross sell products block,



template path :



appdesignfrontenddefaulttheme-nametemplatecheckoutcart



<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category design
* @package base_default
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
/**
* Cart cross sell items template
*
* @see Mage_Checkout_Block_Cart_Crosssell
*/
?>
<?php if($this->getItemCount()): ?>
<div class="crosssell">
<h2><?php echo $this->__('Based on your selection, you may be interested in the following items:') ?></h2>
<ul id="crosssell-products-list">
<?php foreach ($this->getItems() as $_item): ?>
<li class="item">
<a class="product-image" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(110); ?>" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
<div class="product-details">
<h3 class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h3>
<?php echo $this->getPriceHtml($_item, true) ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<ul class="add-to-links">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_item)): ?>
<li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>
</ul>
</div>
</li>
<?php endforeach; ?>
</ul>
<script type="text/javascript">decorateList('crosssell-products-list', 'none-recursive')</script>
</div>
<?php endif; ?>


<?php echo $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml')->toHtml();?>


magento default path :



appdesignfrontendbasedefaulttemplatecheckoutcart



<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category design
* @package base_default
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
/**
* Cart cross sell items template
*
* @see Mage_Checkout_Block_Cart_Crosssell
*/
?>
<?php if($this->getItemCount()): ?>
<div class="crosssell">
<h2><?php echo $this->__('Based on your selection, you may be interested in the following items:') ?></h2>
<ul id="crosssell-products-list">
<?php foreach ($this->getItems() as $_item): ?>
<li class="item">
<a class="product-image" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(75); ?>" width="75" height="75" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
<div class="product-details">
<h3 class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h3>
<?php echo $this->getPriceHtml($_item, true) ?>
<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<ul class="add-to-links">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_item)): ?>
<li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>
</ul>
</div>
</li>
<?php endforeach; ?>
</ul>
<script type="text/javascript">decorateList('crosssell-products-list', 'none-recursive')</script>
</div>
<?php endif; ?>


enter image description here










share|improve this question
















bumped to the homepage by Community 14 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0















    How can i display my cross sell products blocks under add to cart popup box,



    my add to cart block,



    <?php

    class Cmsmart_AjaxCart_IndexController extends Mage_Core_Controller_Front_Action
    {
    public function _constructor(){
    $_SERVER['REQUEST_URI'] = array_pop(explode('web.com', @$_SERVER['HTTP_REFERER']));
    }

    protected function _getCart()
    {
    return Mage::getSingleton('checkout/cart');
    }

    protected function _getSession()
    {
    return Mage::getSingleton('checkout/session');
    }

    protected function _updateShoppingCart()
    {
    try {
    $cartData = $this->getRequest()->getParam('cart');
    if (is_array($cartData)) {
    $filter = new Zend_Filter_LocalizedToNormalized(
    array('locale' => Mage::app()->getLocale()->getLocaleCode())
    );
    foreach ($cartData as $index => $data) {
    if (isset($data['qty'])) {
    $cartData[$index]['qty'] = $filter->filter(trim($data['qty']));
    }
    }
    $cart = $this->_getCart();
    if (! $cart->getCustomerSession()->getCustomer()->getId() && $cart->getQuote()->getCustomerId()) {
    $cart->getQuote()->setCustomerId(null);
    }

    $cartData = $cart->suggestItemsQty($cartData);
    $cart->updateItems($cartData)
    ->save();
    }
    $this->_getSession()->setCartWasUpdated(true);
    } catch (Mage_Core_Exception $e) {
    $this->_getSession()->addError(Mage::helper('core')->escapeHtml($e->getMessage()));
    } catch (Exception $e) {
    $this->_getSession()->addException($e, $this->__('Cannot update shopping cart.'));
    Mage::logException($e);
    }
    }

    public function indexAction(){
    $delete = $this->getRequest()->getParam('delete');
    $kiemtra = true;

    $update = $this->getLayout()->getUpdate();
    $update->addHandle('default');
    $this->addActionLayoutHandles();
    if(!$delete){
    $product = $this->_getProductFromUrl();
    $product = Mage::registry('product');
    $options = $product->getProductOptionsCollection();
    $conf = Mage::getModel('catalog/product_type_configurable')->setProduct($product);
    $col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
    //$kiemtra = (!$product->getTypeInstance(true)->hasRequiredOptions($product) || $this->getRequest()->getParam('product') || count($col) == 0);
    //$kiemtra = ($product->getTypeId() == 'simple' || $this->getRequest()->getParam('product') || $delete) && !$product->getTypeInstance(true)->hasRequiredOptions($product);
    $kiemtra = $delete || $this->getRequest()->getParam('product') || !$product->getTypeInstance(true)->hasRequiredOptions($product);
    if($kiemtra) {
    self::tryaddAction($product, $_GET);
    }

    Mage::dispatchEvent('catalog_controller_product_view', array('product'=>$product));
    if ($this->getRequest()->getParam('options')) {
    $notice = $product->getTypeInstance(true)->getSpecifyOptionMessage();
    Mage::getSingleton('catalog/session')->addNotice($notice);
    }
    if(@$product) Mage::getSingleton('catalog/session')->setLastViewedProductId($product->getId());

    if(@$product){
    $update->addHandle('PRODUCT_TYPE_'.$product->getTypeId());
    $update->addHandle('PRODUCT_'.$product->getId());
    }
    }else{
    $update->addUpdate('<remove name="product.info"/>');
    $kiemtra = true;
    if($delete == 'all'){
    self::_emptyShoppingCart();
    }else{
    if($delete != 'udaj') { $this->removeAction($delete); }else {
    if(@$_POST['cart']) $this->_updateShoppingCart();
    //foreach(@$_POST['cart'] as $k => $v){
    // $this->udpateAction($k, $v);
    }
    }
    }

    $this->loadLayoutUpdates();
    $this->generateLayoutXml()->generateLayoutBlocks();

    $json_encode = array();
    $json_encode['ajaxcart'] = '';
    $json_encode['ajaxsidebar'] = '';
    $json_encode['ajaxSummaryCount'] = '';
    $json_encode['ajaxCountItem'] = '';
    $json_encode['ajaxcartmsg'] = '';
    $json_encode['ajaxcontinue'] = '';

    if($kiemtra) {
    // Show the message add to cart is success
    if(@$product) $json_encode['ajaxcontinue'] = '
    <div>
    <ul class="messages ajaxcart-messages">
    <li class="success-msg">
    <ul>
    <li><span><a title="'.@$product->getName().'" href="'.@$product->getProductUrl().'">'.@$product->getName().' </a> '.$this->__('has been added to cart').'.</span></li>






    <li><button onclick="setLocation(''.Mage::getBaseUrl().'checkout/')" class="button btn-continue" title="'.$this->__('Checkout').'" type="button"><span><span>'.$this->__('Checkout').'</span></span></button>
    </ul>
    </li>
    </ul>
    </div>';

    //<button class="button btn-continue closemsg" title="Continue Shopping" type="button"><span><span>Continue Shopping</span></span></button>
    //<button onclick="setLocation(''.Mage::getBaseUrl().'checkout/onepage/')" class="button btn-continue" title="'.$this->__('Proceed to Checkout').'" type="button"><span><span>'.$this->__('Proceed to Checkout').'</span></span></button>

    // Drop Down Cart Block
    $block = $this->getLayout()->createBlock('checkout/cart_sidebar')->setBlockId('block-id-in-magento')->setTemplate('checkout/cart/sidebar.phtml');
    //$this->getLayout()->getBlock('content')->append($block);
    $count = Mage::helper('checkout/cart')->getSummaryCount();
    if ($count == 1) {
    $text = $this->__('My Cart (%s item)', $count);
    } elseif ($count > 0) {
    $text = $this->__('My Cart (%s items)', $count);
    } else {
    $text = $this->__('My Cart');
    }
    $json_encode['ajaxCountItem'] = $count;
    $json_encode['ajaxSummaryCount'] = $text;
    $json_encode['ajaxsidebar'] = str_replace('class="block block-cart"', 'id="cart-ajax-sidebar"', @$block->toHtml());

    $block2 = $this->getLayout()->createBlock('checkout/cart_sidebar')
    ->setTemplate('cmsmart/ajaxcart/view/sidebar.phtml')
    ->addItemRender('simple', 'checkout/cart_item_renderer', 'cmsmart/ajaxcart/view/sidebar/default.phtml')
    ->addItemRender('grouped', 'checkout/cart_item_renderer', 'cmsmart/ajaxcart/view/sidebar/default.phtml')
    ->addItemRender('configurable', 'checkout/cart_item_renderer', 'cmsmart/ajaxcart/view/sidebar/default.phtml');

    $json_encode['ajaxcart'] = @$block2->toHtml();

    }else{
    $json_encode['ajaxcartmsg'] = $this->getLayout()->getBlock('content')->toHtml();
    }
    echo json_encode($json_encode);
    }

    private function tryaddAction($product, $params = array()){

    $cart = Mage::getModel("checkout/cart");
    $cart->addProduct($product->getId(), $params);
    return $cart->save();
    }

    private function udpateAction($itemId, $qty){
    $qty = (int)$qty?(int)$qty:1;
    $cartHelper = Mage::getSingleton('checkout/cart');
    $cartHelper->updateItem($itemId, $qty);
    //$items = $cartHelper->getCart()->getItems();
    // foreach ($items as $item) {
    // if ($item->getId() == $itemId) {
    // $item->setQty($qty);
    // }
    // }
    $cartHelper->save();
    Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
    }

    private function removeAction($itemId){
    try{
    $cartHelper = Mage::helper('checkout/cart');
    $cartHelper->getCart()->removeItem($itemId)->save();
    }catch (Mage_Core_Exception $exception) {}
    }

    private function emptyAction(){
    $cartHelper = Mage::helper('checkout/cart');
    $items = $cartHelper->getCart()->getItems();
    foreach ($items as $item) {
    $cartHelper->getCart()->removeItem($item->getItemId());
    }
    $cartHelper->getCart()->save();
    }

    protected function _emptyShoppingCart()
    {
    try {
    $this->_getCart()->truncate()->save();
    $this->_getSession()->setCartWasUpdated(true);
    } catch (Mage_Core_Exception $exception) {
    $this->_getSession()->addError($exception->getMessage());
    } catch (Exception $exception) {
    $this->_getSession()->addException($exception, $this->__('Cannot update shopping cart.'));
    }
    }

    public function _getProductFromUrl(){
    Mage::dispatchEvent('catalog_controller_product_init_before', array('controller_action'=>$this));
    $product_id = $this->getRequest()->getParam('product');
    if(!$product_id):
    $path = $this->getRequest()->getParam('id');
    $product_id = (int) $path;

    if(!$product_id){

    $path[0] == "/" ? $path = substr($path, 1, strlen($path)) : $path;
    $tableName = Mage::getSingleton('core/resource')->getTableName('core_url_rewrite');
    $write = Mage::getSingleton('core/resource')->getConnection('core_write');

    $rs = $write->query('select `product_id` from `'.$tableName.'` where `request_path` = "'.$path.'"');

    if ($row = $rs->fetch() ) {
    $product_id = $row['product_id'];
    }
    }
    endif;

    if (!$product_id) {
    return false;
    }

    $product = Mage::getModel('catalog/product')
    ->setStoreId(Mage::app()->getStore()->getId())
    ->load($product_id);

    if (!Mage::helper('catalog/product')->canShow($product)) {
    return false;
    }
    if (!in_array(Mage::app()->getStore()->getWebsiteId(), $product->getWebsiteIds())) {
    return false;
    }

    $category = null;
    if ($categoryId) {
    $category = Mage::getModel('catalog/category')->load($categoryId);
    $product->setCategory($category);
    Mage::register('current_category', $category);
    }
    elseif ($categoryId = Mage::getSingleton('catalog/session')->getLastVisitedCategoryId()) {
    if ($product->canBeShowInCategory($categoryId)) {
    $category = Mage::getModel('catalog/category')->load($categoryId);
    $product->setCategory($category);
    Mage::register('current_category', $category);
    }
    }
    Mage::register('current_product', $product);
    Mage::register('product', $product);

    try {
    Mage::dispatchEvent('catalog_controller_product_init', array('product'=>$product));
    Mage::dispatchEvent('catalog_controller_product_init_after', array('product'=>$product, 'controller_action' => $this));
    } catch (Mage_Core_Exception $e) {
    Mage::logException($e);
    return false;
    }

    return $product;
    }


    }


    my cross sell products block,



    template path :



    appdesignfrontenddefaulttheme-nametemplatecheckoutcart



    <?php
    /**
    * Magento
    *
    * NOTICE OF LICENSE
    *
    * This source file is subject to the Academic Free License (AFL 3.0)
    * that is bundled with this package in the file LICENSE_AFL.txt.
    * It is also available through the world-wide-web at this URL:
    * http://opensource.org/licenses/afl-3.0.php
    * If you did not receive a copy of the license and are unable to
    * obtain it through the world-wide-web, please send an email
    * to license@magentocommerce.com so we can send you a copy immediately.
    *
    * DISCLAIMER
    *
    * Do not edit or add to this file if you wish to upgrade Magento to newer
    * versions in the future. If you wish to customize Magento for your
    * needs please refer to http://www.magentocommerce.com for more information.
    *
    * @category design
    * @package base_default
    * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
    * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
    */
    ?>
    <?php
    /**
    * Cart cross sell items template
    *
    * @see Mage_Checkout_Block_Cart_Crosssell
    */
    ?>
    <?php if($this->getItemCount()): ?>
    <div class="crosssell">
    <h2><?php echo $this->__('Based on your selection, you may be interested in the following items:') ?></h2>
    <ul id="crosssell-products-list">
    <?php foreach ($this->getItems() as $_item): ?>
    <li class="item">
    <a class="product-image" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(110); ?>" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
    <div class="product-details">
    <h3 class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h3>
    <?php echo $this->getPriceHtml($_item, true) ?>
    <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
    <ul class="add-to-links">
    <?php if ($this->helper('wishlist')->isAllow()) : ?>
    <li><a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
    <?php endif; ?>
    <?php if($_compareUrl=$this->getAddToCompareUrl($_item)): ?>
    <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
    <?php endif; ?>
    </ul>
    </div>
    </li>
    <?php endforeach; ?>
    </ul>
    <script type="text/javascript">decorateList('crosssell-products-list', 'none-recursive')</script>
    </div>
    <?php endif; ?>


    <?php echo $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml')->toHtml();?>


    magento default path :



    appdesignfrontendbasedefaulttemplatecheckoutcart



    <?php
    /**
    * Magento
    *
    * NOTICE OF LICENSE
    *
    * This source file is subject to the Academic Free License (AFL 3.0)
    * that is bundled with this package in the file LICENSE_AFL.txt.
    * It is also available through the world-wide-web at this URL:
    * http://opensource.org/licenses/afl-3.0.php
    * If you did not receive a copy of the license and are unable to
    * obtain it through the world-wide-web, please send an email
    * to license@magento.com so we can send you a copy immediately.
    *
    * DISCLAIMER
    *
    * Do not edit or add to this file if you wish to upgrade Magento to newer
    * versions in the future. If you wish to customize Magento for your
    * needs please refer to http://www.magento.com for more information.
    *
    * @category design
    * @package base_default
    * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
    * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
    */
    ?>
    <?php
    /**
    * Cart cross sell items template
    *
    * @see Mage_Checkout_Block_Cart_Crosssell
    */
    ?>
    <?php if($this->getItemCount()): ?>
    <div class="crosssell">
    <h2><?php echo $this->__('Based on your selection, you may be interested in the following items:') ?></h2>
    <ul id="crosssell-products-list">
    <?php foreach ($this->getItems() as $_item): ?>
    <li class="item">
    <a class="product-image" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(75); ?>" width="75" height="75" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
    <div class="product-details">
    <h3 class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h3>
    <?php echo $this->getPriceHtml($_item, true) ?>
    <button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
    <ul class="add-to-links">
    <?php if ($this->helper('wishlist')->isAllow()) : ?>
    <li><a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
    <?php endif; ?>
    <?php if($_compareUrl=$this->getAddToCompareUrl($_item)): ?>
    <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
    <?php endif; ?>
    </ul>
    </div>
    </li>
    <?php endforeach; ?>
    </ul>
    <script type="text/javascript">decorateList('crosssell-products-list', 'none-recursive')</script>
    </div>
    <?php endif; ?>


    enter image description here










    share|improve this question
















    bumped to the homepage by Community 14 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0


      1






      How can i display my cross sell products blocks under add to cart popup box,



      my add to cart block,



      <?php

      class Cmsmart_AjaxCart_IndexController extends Mage_Core_Controller_Front_Action
      {
      public function _constructor(){
      $_SERVER['REQUEST_URI'] = array_pop(explode('web.com', @$_SERVER['HTTP_REFERER']));
      }

      protected function _getCart()
      {
      return Mage::getSingleton('checkout/cart');
      }

      protected function _getSession()
      {
      return Mage::getSingleton('checkout/session');
      }

      protected function _updateShoppingCart()
      {
      try {
      $cartData = $this->getRequest()->getParam('cart');
      if (is_array($cartData)) {
      $filter = new Zend_Filter_LocalizedToNormalized(
      array('locale' => Mage::app()->getLocale()->getLocaleCode())
      );
      foreach ($cartData as $index => $data) {
      if (isset($data['qty'])) {
      $cartData[$index]['qty'] = $filter->filter(trim($data['qty']));
      }
      }
      $cart = $this->_getCart();
      if (! $cart->getCustomerSession()->getCustomer()->getId() && $cart->getQuote()->getCustomerId()) {
      $cart->getQuote()->setCustomerId(null);
      }

      $cartData = $cart->suggestItemsQty($cartData);
      $cart->updateItems($cartData)
      ->save();
      }
      $this->_getSession()->setCartWasUpdated(true);
      } catch (Mage_Core_Exception $e) {
      $this->_getSession()->addError(Mage::helper('core')->escapeHtml($e->getMessage()));
      } catch (Exception $e) {
      $this->_getSession()->addException($e, $this->__('Cannot update shopping cart.'));
      Mage::logException($e);
      }
      }

      public function indexAction(){
      $delete = $this->getRequest()->getParam('delete');
      $kiemtra = true;

      $update = $this->getLayout()->getUpdate();
      $update->addHandle('default');
      $this->addActionLayoutHandles();
      if(!$delete){
      $product = $this->_getProductFromUrl();
      $product = Mage::registry('product');
      $options = $product->getProductOptionsCollection();
      $conf = Mage::getModel('catalog/product_type_configurable')->setProduct($product);
      $col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
      //$kiemtra = (!$product->getTypeInstance(true)->hasRequiredOptions($product) || $this->getRequest()->getParam('product') || count($col) == 0);
      //$kiemtra = ($product->getTypeId() == 'simple' || $this->getRequest()->getParam('product') || $delete) && !$product->getTypeInstance(true)->hasRequiredOptions($product);
      $kiemtra = $delete || $this->getRequest()->getParam('product') || !$product->getTypeInstance(true)->hasRequiredOptions($product);
      if($kiemtra) {
      self::tryaddAction($product, $_GET);
      }

      Mage::dispatchEvent('catalog_controller_product_view', array('product'=>$product));
      if ($this->getRequest()->getParam('options')) {
      $notice = $product->getTypeInstance(true)->getSpecifyOptionMessage();
      Mage::getSingleton('catalog/session')->addNotice($notice);
      }
      if(@$product) Mage::getSingleton('catalog/session')->setLastViewedProductId($product->getId());

      if(@$product){
      $update->addHandle('PRODUCT_TYPE_'.$product->getTypeId());
      $update->addHandle('PRODUCT_'.$product->getId());
      }
      }else{
      $update->addUpdate('<remove name="product.info"/>');
      $kiemtra = true;
      if($delete == 'all'){
      self::_emptyShoppingCart();
      }else{
      if($delete != 'udaj') { $this->removeAction($delete); }else {
      if(@$_POST['cart']) $this->_updateShoppingCart();
      //foreach(@$_POST['cart'] as $k => $v){
      // $this->udpateAction($k, $v);
      }
      }
      }

      $this->loadLayoutUpdates();
      $this->generateLayoutXml()->generateLayoutBlocks();

      $json_encode = array();
      $json_encode['ajaxcart'] = '';
      $json_encode['ajaxsidebar'] = '';
      $json_encode['ajaxSummaryCount'] = '';
      $json_encode['ajaxCountItem'] = '';
      $json_encode['ajaxcartmsg'] = '';
      $json_encode['ajaxcontinue'] = '';

      if($kiemtra) {
      // Show the message add to cart is success
      if(@$product) $json_encode['ajaxcontinue'] = '
      <div>
      <ul class="messages ajaxcart-messages">
      <li class="success-msg">
      <ul>
      <li><span><a title="'.@$product->getName().'" href="'.@$product->getProductUrl().'">'.@$product->getName().' </a> '.$this->__('has been added to cart').'.</span></li>






      <li><button onclick="setLocation(''.Mage::getBaseUrl().'checkout/')" class="button btn-continue" title="'.$this->__('Checkout').'" type="button"><span><span>'.$this->__('Checkout').'</span></span></button>
      </ul>
      </li>
      </ul>
      </div>';

      //<button class="button btn-continue closemsg" title="Continue Shopping" type="button"><span><span>Continue Shopping</span></span></button>
      //<button onclick="setLocation(''.Mage::getBaseUrl().'checkout/onepage/')" class="button btn-continue" title="'.$this->__('Proceed to Checkout').'" type="button"><span><span>'.$this->__('Proceed to Checkout').'</span></span></button>

      // Drop Down Cart Block
      $block = $this->getLayout()->createBlock('checkout/cart_sidebar')->setBlockId('block-id-in-magento')->setTemplate('checkout/cart/sidebar.phtml');
      //$this->getLayout()->getBlock('content')->append($block);
      $count = Mage::helper('checkout/cart')->getSummaryCount();
      if ($count == 1) {
      $text = $this->__('My Cart (%s item)', $count);
      } elseif ($count > 0) {
      $text = $this->__('My Cart (%s items)', $count);
      } else {
      $text = $this->__('My Cart');
      }
      $json_encode['ajaxCountItem'] = $count;
      $json_encode['ajaxSummaryCount'] = $text;
      $json_encode['ajaxsidebar'] = str_replace('class="block block-cart"', 'id="cart-ajax-sidebar"', @$block->toHtml());

      $block2 = $this->getLayout()->createBlock('checkout/cart_sidebar')
      ->setTemplate('cmsmart/ajaxcart/view/sidebar.phtml')
      ->addItemRender('simple', 'checkout/cart_item_renderer', 'cmsmart/ajaxcart/view/sidebar/default.phtml')
      ->addItemRender('grouped', 'checkout/cart_item_renderer', 'cmsmart/ajaxcart/view/sidebar/default.phtml')
      ->addItemRender('configurable', 'checkout/cart_item_renderer', 'cmsmart/ajaxcart/view/sidebar/default.phtml');

      $json_encode['ajaxcart'] = @$block2->toHtml();

      }else{
      $json_encode['ajaxcartmsg'] = $this->getLayout()->getBlock('content')->toHtml();
      }
      echo json_encode($json_encode);
      }

      private function tryaddAction($product, $params = array()){

      $cart = Mage::getModel("checkout/cart");
      $cart->addProduct($product->getId(), $params);
      return $cart->save();
      }

      private function udpateAction($itemId, $qty){
      $qty = (int)$qty?(int)$qty:1;
      $cartHelper = Mage::getSingleton('checkout/cart');
      $cartHelper->updateItem($itemId, $qty);
      //$items = $cartHelper->getCart()->getItems();
      // foreach ($items as $item) {
      // if ($item->getId() == $itemId) {
      // $item->setQty($qty);
      // }
      // }
      $cartHelper->save();
      Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
      }

      private function removeAction($itemId){
      try{
      $cartHelper = Mage::helper('checkout/cart');
      $cartHelper->getCart()->removeItem($itemId)->save();
      }catch (Mage_Core_Exception $exception) {}
      }

      private function emptyAction(){
      $cartHelper = Mage::helper('checkout/cart');
      $items = $cartHelper->getCart()->getItems();
      foreach ($items as $item) {
      $cartHelper->getCart()->removeItem($item->getItemId());
      }
      $cartHelper->getCart()->save();
      }

      protected function _emptyShoppingCart()
      {
      try {
      $this->_getCart()->truncate()->save();
      $this->_getSession()->setCartWasUpdated(true);
      } catch (Mage_Core_Exception $exception) {
      $this->_getSession()->addError($exception->getMessage());
      } catch (Exception $exception) {
      $this->_getSession()->addException($exception, $this->__('Cannot update shopping cart.'));
      }
      }

      public function _getProductFromUrl(){
      Mage::dispatchEvent('catalog_controller_product_init_before', array('controller_action'=>$this));
      $product_id = $this->getRequest()->getParam('product');
      if(!$product_id):
      $path = $this->getRequest()->getParam('id');
      $product_id = (int) $path;

      if(!$product_id){

      $path[0] == "/" ? $path = substr($path, 1, strlen($path)) : $path;
      $tableName = Mage::getSingleton('core/resource')->getTableName('core_url_rewrite');
      $write = Mage::getSingleton('core/resource')->getConnection('core_write');

      $rs = $write->query('select `product_id` from `'.$tableName.'` where `request_path` = "'.$path.'"');

      if ($row = $rs->fetch() ) {
      $product_id = $row['product_id'];
      }
      }
      endif;

      if (!$product_id) {
      return false;
      }

      $product = Mage::getModel('catalog/product')
      ->setStoreId(Mage::app()->getStore()->getId())
      ->load($product_id);

      if (!Mage::helper('catalog/product')->canShow($product)) {
      return false;
      }
      if (!in_array(Mage::app()->getStore()->getWebsiteId(), $product->getWebsiteIds())) {
      return false;
      }

      $category = null;
      if ($categoryId) {
      $category = Mage::getModel('catalog/category')->load($categoryId);
      $product->setCategory($category);
      Mage::register('current_category', $category);
      }
      elseif ($categoryId = Mage::getSingleton('catalog/session')->getLastVisitedCategoryId()) {
      if ($product->canBeShowInCategory($categoryId)) {
      $category = Mage::getModel('catalog/category')->load($categoryId);
      $product->setCategory($category);
      Mage::register('current_category', $category);
      }
      }
      Mage::register('current_product', $product);
      Mage::register('product', $product);

      try {
      Mage::dispatchEvent('catalog_controller_product_init', array('product'=>$product));
      Mage::dispatchEvent('catalog_controller_product_init_after', array('product'=>$product, 'controller_action' => $this));
      } catch (Mage_Core_Exception $e) {
      Mage::logException($e);
      return false;
      }

      return $product;
      }


      }


      my cross sell products block,



      template path :



      appdesignfrontenddefaulttheme-nametemplatecheckoutcart



      <?php
      /**
      * Magento
      *
      * NOTICE OF LICENSE
      *
      * This source file is subject to the Academic Free License (AFL 3.0)
      * that is bundled with this package in the file LICENSE_AFL.txt.
      * It is also available through the world-wide-web at this URL:
      * http://opensource.org/licenses/afl-3.0.php
      * If you did not receive a copy of the license and are unable to
      * obtain it through the world-wide-web, please send an email
      * to license@magentocommerce.com so we can send you a copy immediately.
      *
      * DISCLAIMER
      *
      * Do not edit or add to this file if you wish to upgrade Magento to newer
      * versions in the future. If you wish to customize Magento for your
      * needs please refer to http://www.magentocommerce.com for more information.
      *
      * @category design
      * @package base_default
      * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
      * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
      */
      ?>
      <?php
      /**
      * Cart cross sell items template
      *
      * @see Mage_Checkout_Block_Cart_Crosssell
      */
      ?>
      <?php if($this->getItemCount()): ?>
      <div class="crosssell">
      <h2><?php echo $this->__('Based on your selection, you may be interested in the following items:') ?></h2>
      <ul id="crosssell-products-list">
      <?php foreach ($this->getItems() as $_item): ?>
      <li class="item">
      <a class="product-image" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(110); ?>" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
      <div class="product-details">
      <h3 class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h3>
      <?php echo $this->getPriceHtml($_item, true) ?>
      <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
      <ul class="add-to-links">
      <?php if ($this->helper('wishlist')->isAllow()) : ?>
      <li><a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
      <?php endif; ?>
      <?php if($_compareUrl=$this->getAddToCompareUrl($_item)): ?>
      <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
      <?php endif; ?>
      </ul>
      </div>
      </li>
      <?php endforeach; ?>
      </ul>
      <script type="text/javascript">decorateList('crosssell-products-list', 'none-recursive')</script>
      </div>
      <?php endif; ?>


      <?php echo $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml')->toHtml();?>


      magento default path :



      appdesignfrontendbasedefaulttemplatecheckoutcart



      <?php
      /**
      * Magento
      *
      * NOTICE OF LICENSE
      *
      * This source file is subject to the Academic Free License (AFL 3.0)
      * that is bundled with this package in the file LICENSE_AFL.txt.
      * It is also available through the world-wide-web at this URL:
      * http://opensource.org/licenses/afl-3.0.php
      * If you did not receive a copy of the license and are unable to
      * obtain it through the world-wide-web, please send an email
      * to license@magento.com so we can send you a copy immediately.
      *
      * DISCLAIMER
      *
      * Do not edit or add to this file if you wish to upgrade Magento to newer
      * versions in the future. If you wish to customize Magento for your
      * needs please refer to http://www.magento.com for more information.
      *
      * @category design
      * @package base_default
      * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
      * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
      */
      ?>
      <?php
      /**
      * Cart cross sell items template
      *
      * @see Mage_Checkout_Block_Cart_Crosssell
      */
      ?>
      <?php if($this->getItemCount()): ?>
      <div class="crosssell">
      <h2><?php echo $this->__('Based on your selection, you may be interested in the following items:') ?></h2>
      <ul id="crosssell-products-list">
      <?php foreach ($this->getItems() as $_item): ?>
      <li class="item">
      <a class="product-image" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(75); ?>" width="75" height="75" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
      <div class="product-details">
      <h3 class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h3>
      <?php echo $this->getPriceHtml($_item, true) ?>
      <button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
      <ul class="add-to-links">
      <?php if ($this->helper('wishlist')->isAllow()) : ?>
      <li><a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
      <?php endif; ?>
      <?php if($_compareUrl=$this->getAddToCompareUrl($_item)): ?>
      <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
      <?php endif; ?>
      </ul>
      </div>
      </li>
      <?php endforeach; ?>
      </ul>
      <script type="text/javascript">decorateList('crosssell-products-list', 'none-recursive')</script>
      </div>
      <?php endif; ?>


      enter image description here










      share|improve this question
















      How can i display my cross sell products blocks under add to cart popup box,



      my add to cart block,



      <?php

      class Cmsmart_AjaxCart_IndexController extends Mage_Core_Controller_Front_Action
      {
      public function _constructor(){
      $_SERVER['REQUEST_URI'] = array_pop(explode('web.com', @$_SERVER['HTTP_REFERER']));
      }

      protected function _getCart()
      {
      return Mage::getSingleton('checkout/cart');
      }

      protected function _getSession()
      {
      return Mage::getSingleton('checkout/session');
      }

      protected function _updateShoppingCart()
      {
      try {
      $cartData = $this->getRequest()->getParam('cart');
      if (is_array($cartData)) {
      $filter = new Zend_Filter_LocalizedToNormalized(
      array('locale' => Mage::app()->getLocale()->getLocaleCode())
      );
      foreach ($cartData as $index => $data) {
      if (isset($data['qty'])) {
      $cartData[$index]['qty'] = $filter->filter(trim($data['qty']));
      }
      }
      $cart = $this->_getCart();
      if (! $cart->getCustomerSession()->getCustomer()->getId() && $cart->getQuote()->getCustomerId()) {
      $cart->getQuote()->setCustomerId(null);
      }

      $cartData = $cart->suggestItemsQty($cartData);
      $cart->updateItems($cartData)
      ->save();
      }
      $this->_getSession()->setCartWasUpdated(true);
      } catch (Mage_Core_Exception $e) {
      $this->_getSession()->addError(Mage::helper('core')->escapeHtml($e->getMessage()));
      } catch (Exception $e) {
      $this->_getSession()->addException($e, $this->__('Cannot update shopping cart.'));
      Mage::logException($e);
      }
      }

      public function indexAction(){
      $delete = $this->getRequest()->getParam('delete');
      $kiemtra = true;

      $update = $this->getLayout()->getUpdate();
      $update->addHandle('default');
      $this->addActionLayoutHandles();
      if(!$delete){
      $product = $this->_getProductFromUrl();
      $product = Mage::registry('product');
      $options = $product->getProductOptionsCollection();
      $conf = Mage::getModel('catalog/product_type_configurable')->setProduct($product);
      $col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
      //$kiemtra = (!$product->getTypeInstance(true)->hasRequiredOptions($product) || $this->getRequest()->getParam('product') || count($col) == 0);
      //$kiemtra = ($product->getTypeId() == 'simple' || $this->getRequest()->getParam('product') || $delete) && !$product->getTypeInstance(true)->hasRequiredOptions($product);
      $kiemtra = $delete || $this->getRequest()->getParam('product') || !$product->getTypeInstance(true)->hasRequiredOptions($product);
      if($kiemtra) {
      self::tryaddAction($product, $_GET);
      }

      Mage::dispatchEvent('catalog_controller_product_view', array('product'=>$product));
      if ($this->getRequest()->getParam('options')) {
      $notice = $product->getTypeInstance(true)->getSpecifyOptionMessage();
      Mage::getSingleton('catalog/session')->addNotice($notice);
      }
      if(@$product) Mage::getSingleton('catalog/session')->setLastViewedProductId($product->getId());

      if(@$product){
      $update->addHandle('PRODUCT_TYPE_'.$product->getTypeId());
      $update->addHandle('PRODUCT_'.$product->getId());
      }
      }else{
      $update->addUpdate('<remove name="product.info"/>');
      $kiemtra = true;
      if($delete == 'all'){
      self::_emptyShoppingCart();
      }else{
      if($delete != 'udaj') { $this->removeAction($delete); }else {
      if(@$_POST['cart']) $this->_updateShoppingCart();
      //foreach(@$_POST['cart'] as $k => $v){
      // $this->udpateAction($k, $v);
      }
      }
      }

      $this->loadLayoutUpdates();
      $this->generateLayoutXml()->generateLayoutBlocks();

      $json_encode = array();
      $json_encode['ajaxcart'] = '';
      $json_encode['ajaxsidebar'] = '';
      $json_encode['ajaxSummaryCount'] = '';
      $json_encode['ajaxCountItem'] = '';
      $json_encode['ajaxcartmsg'] = '';
      $json_encode['ajaxcontinue'] = '';

      if($kiemtra) {
      // Show the message add to cart is success
      if(@$product) $json_encode['ajaxcontinue'] = '
      <div>
      <ul class="messages ajaxcart-messages">
      <li class="success-msg">
      <ul>
      <li><span><a title="'.@$product->getName().'" href="'.@$product->getProductUrl().'">'.@$product->getName().' </a> '.$this->__('has been added to cart').'.</span></li>






      <li><button onclick="setLocation(''.Mage::getBaseUrl().'checkout/')" class="button btn-continue" title="'.$this->__('Checkout').'" type="button"><span><span>'.$this->__('Checkout').'</span></span></button>
      </ul>
      </li>
      </ul>
      </div>';

      //<button class="button btn-continue closemsg" title="Continue Shopping" type="button"><span><span>Continue Shopping</span></span></button>
      //<button onclick="setLocation(''.Mage::getBaseUrl().'checkout/onepage/')" class="button btn-continue" title="'.$this->__('Proceed to Checkout').'" type="button"><span><span>'.$this->__('Proceed to Checkout').'</span></span></button>

      // Drop Down Cart Block
      $block = $this->getLayout()->createBlock('checkout/cart_sidebar')->setBlockId('block-id-in-magento')->setTemplate('checkout/cart/sidebar.phtml');
      //$this->getLayout()->getBlock('content')->append($block);
      $count = Mage::helper('checkout/cart')->getSummaryCount();
      if ($count == 1) {
      $text = $this->__('My Cart (%s item)', $count);
      } elseif ($count > 0) {
      $text = $this->__('My Cart (%s items)', $count);
      } else {
      $text = $this->__('My Cart');
      }
      $json_encode['ajaxCountItem'] = $count;
      $json_encode['ajaxSummaryCount'] = $text;
      $json_encode['ajaxsidebar'] = str_replace('class="block block-cart"', 'id="cart-ajax-sidebar"', @$block->toHtml());

      $block2 = $this->getLayout()->createBlock('checkout/cart_sidebar')
      ->setTemplate('cmsmart/ajaxcart/view/sidebar.phtml')
      ->addItemRender('simple', 'checkout/cart_item_renderer', 'cmsmart/ajaxcart/view/sidebar/default.phtml')
      ->addItemRender('grouped', 'checkout/cart_item_renderer', 'cmsmart/ajaxcart/view/sidebar/default.phtml')
      ->addItemRender('configurable', 'checkout/cart_item_renderer', 'cmsmart/ajaxcart/view/sidebar/default.phtml');

      $json_encode['ajaxcart'] = @$block2->toHtml();

      }else{
      $json_encode['ajaxcartmsg'] = $this->getLayout()->getBlock('content')->toHtml();
      }
      echo json_encode($json_encode);
      }

      private function tryaddAction($product, $params = array()){

      $cart = Mage::getModel("checkout/cart");
      $cart->addProduct($product->getId(), $params);
      return $cart->save();
      }

      private function udpateAction($itemId, $qty){
      $qty = (int)$qty?(int)$qty:1;
      $cartHelper = Mage::getSingleton('checkout/cart');
      $cartHelper->updateItem($itemId, $qty);
      //$items = $cartHelper->getCart()->getItems();
      // foreach ($items as $item) {
      // if ($item->getId() == $itemId) {
      // $item->setQty($qty);
      // }
      // }
      $cartHelper->save();
      Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
      }

      private function removeAction($itemId){
      try{
      $cartHelper = Mage::helper('checkout/cart');
      $cartHelper->getCart()->removeItem($itemId)->save();
      }catch (Mage_Core_Exception $exception) {}
      }

      private function emptyAction(){
      $cartHelper = Mage::helper('checkout/cart');
      $items = $cartHelper->getCart()->getItems();
      foreach ($items as $item) {
      $cartHelper->getCart()->removeItem($item->getItemId());
      }
      $cartHelper->getCart()->save();
      }

      protected function _emptyShoppingCart()
      {
      try {
      $this->_getCart()->truncate()->save();
      $this->_getSession()->setCartWasUpdated(true);
      } catch (Mage_Core_Exception $exception) {
      $this->_getSession()->addError($exception->getMessage());
      } catch (Exception $exception) {
      $this->_getSession()->addException($exception, $this->__('Cannot update shopping cart.'));
      }
      }

      public function _getProductFromUrl(){
      Mage::dispatchEvent('catalog_controller_product_init_before', array('controller_action'=>$this));
      $product_id = $this->getRequest()->getParam('product');
      if(!$product_id):
      $path = $this->getRequest()->getParam('id');
      $product_id = (int) $path;

      if(!$product_id){

      $path[0] == "/" ? $path = substr($path, 1, strlen($path)) : $path;
      $tableName = Mage::getSingleton('core/resource')->getTableName('core_url_rewrite');
      $write = Mage::getSingleton('core/resource')->getConnection('core_write');

      $rs = $write->query('select `product_id` from `'.$tableName.'` where `request_path` = "'.$path.'"');

      if ($row = $rs->fetch() ) {
      $product_id = $row['product_id'];
      }
      }
      endif;

      if (!$product_id) {
      return false;
      }

      $product = Mage::getModel('catalog/product')
      ->setStoreId(Mage::app()->getStore()->getId())
      ->load($product_id);

      if (!Mage::helper('catalog/product')->canShow($product)) {
      return false;
      }
      if (!in_array(Mage::app()->getStore()->getWebsiteId(), $product->getWebsiteIds())) {
      return false;
      }

      $category = null;
      if ($categoryId) {
      $category = Mage::getModel('catalog/category')->load($categoryId);
      $product->setCategory($category);
      Mage::register('current_category', $category);
      }
      elseif ($categoryId = Mage::getSingleton('catalog/session')->getLastVisitedCategoryId()) {
      if ($product->canBeShowInCategory($categoryId)) {
      $category = Mage::getModel('catalog/category')->load($categoryId);
      $product->setCategory($category);
      Mage::register('current_category', $category);
      }
      }
      Mage::register('current_product', $product);
      Mage::register('product', $product);

      try {
      Mage::dispatchEvent('catalog_controller_product_init', array('product'=>$product));
      Mage::dispatchEvent('catalog_controller_product_init_after', array('product'=>$product, 'controller_action' => $this));
      } catch (Mage_Core_Exception $e) {
      Mage::logException($e);
      return false;
      }

      return $product;
      }


      }


      my cross sell products block,



      template path :



      appdesignfrontenddefaulttheme-nametemplatecheckoutcart



      <?php
      /**
      * Magento
      *
      * NOTICE OF LICENSE
      *
      * This source file is subject to the Academic Free License (AFL 3.0)
      * that is bundled with this package in the file LICENSE_AFL.txt.
      * It is also available through the world-wide-web at this URL:
      * http://opensource.org/licenses/afl-3.0.php
      * If you did not receive a copy of the license and are unable to
      * obtain it through the world-wide-web, please send an email
      * to license@magentocommerce.com so we can send you a copy immediately.
      *
      * DISCLAIMER
      *
      * Do not edit or add to this file if you wish to upgrade Magento to newer
      * versions in the future. If you wish to customize Magento for your
      * needs please refer to http://www.magentocommerce.com for more information.
      *
      * @category design
      * @package base_default
      * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
      * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
      */
      ?>
      <?php
      /**
      * Cart cross sell items template
      *
      * @see Mage_Checkout_Block_Cart_Crosssell
      */
      ?>
      <?php if($this->getItemCount()): ?>
      <div class="crosssell">
      <h2><?php echo $this->__('Based on your selection, you may be interested in the following items:') ?></h2>
      <ul id="crosssell-products-list">
      <?php foreach ($this->getItems() as $_item): ?>
      <li class="item">
      <a class="product-image" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(110); ?>" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
      <div class="product-details">
      <h3 class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h3>
      <?php echo $this->getPriceHtml($_item, true) ?>
      <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
      <ul class="add-to-links">
      <?php if ($this->helper('wishlist')->isAllow()) : ?>
      <li><a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
      <?php endif; ?>
      <?php if($_compareUrl=$this->getAddToCompareUrl($_item)): ?>
      <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
      <?php endif; ?>
      </ul>
      </div>
      </li>
      <?php endforeach; ?>
      </ul>
      <script type="text/javascript">decorateList('crosssell-products-list', 'none-recursive')</script>
      </div>
      <?php endif; ?>


      <?php echo $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml')->toHtml();?>


      magento default path :



      appdesignfrontendbasedefaulttemplatecheckoutcart



      <?php
      /**
      * Magento
      *
      * NOTICE OF LICENSE
      *
      * This source file is subject to the Academic Free License (AFL 3.0)
      * that is bundled with this package in the file LICENSE_AFL.txt.
      * It is also available through the world-wide-web at this URL:
      * http://opensource.org/licenses/afl-3.0.php
      * If you did not receive a copy of the license and are unable to
      * obtain it through the world-wide-web, please send an email
      * to license@magento.com so we can send you a copy immediately.
      *
      * DISCLAIMER
      *
      * Do not edit or add to this file if you wish to upgrade Magento to newer
      * versions in the future. If you wish to customize Magento for your
      * needs please refer to http://www.magento.com for more information.
      *
      * @category design
      * @package base_default
      * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
      * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
      */
      ?>
      <?php
      /**
      * Cart cross sell items template
      *
      * @see Mage_Checkout_Block_Cart_Crosssell
      */
      ?>
      <?php if($this->getItemCount()): ?>
      <div class="crosssell">
      <h2><?php echo $this->__('Based on your selection, you may be interested in the following items:') ?></h2>
      <ul id="crosssell-products-list">
      <?php foreach ($this->getItems() as $_item): ?>
      <li class="item">
      <a class="product-image" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(75); ?>" width="75" height="75" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
      <div class="product-details">
      <h3 class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h3>
      <?php echo $this->getPriceHtml($_item, true) ?>
      <button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
      <ul class="add-to-links">
      <?php if ($this->helper('wishlist')->isAllow()) : ?>
      <li><a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
      <?php endif; ?>
      <?php if($_compareUrl=$this->getAddToCompareUrl($_item)): ?>
      <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
      <?php endif; ?>
      </ul>
      </div>
      </li>
      <?php endforeach; ?>
      </ul>
      <script type="text/javascript">decorateList('crosssell-products-list', 'none-recursive')</script>
      </div>
      <?php endif; ?>


      enter image description here







      magento-1.9 cart addtocart cross-sells popup






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 26 '16 at 12:38







      Gem

















      asked Aug 26 '16 at 4:27









      GemGem

      143632




      143632





      bumped to the homepage by Community 14 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 14 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Hi You can do that by adding crosssell block html in you ajax response in your controller ajax action.



          $this->loadLayout();
          $block = $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml');
          $response['crosssell'] = $block->toHtml();
          $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));


          Now you can access this response crosssell block html in Ajax success block and can add it in popup html.



          I Hope this will be helpful to you.






          share|improve this answer


























          • @ could to pls join chat, chat.stackexchange.com/rooms/44517/…

            – Gem
            Aug 26 '16 at 8:37











          • chat.stackexchange.com/rooms/44517/…

            – Gem
            Aug 26 '16 at 8:38











          • not working after add your code

            – Gem
            Aug 26 '16 at 11:40











          • i.imgur.com/7LG4oby.png

            – Gem
            Aug 26 '16 at 11:40











          • @JeevaRathinam Sorry for late reply..i have updated answer please check.

            – Hardik Shah
            Aug 26 '16 at 14:08



















          0














          Write this code in popup area file and you



          {{block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"}}


          Means call crosssell.phtml file in popup window.
          And this is the code for it.



          <?php echo $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml')->toHtml();?>


          And design it as per you need.






          share|improve this answer


























          • i.imgur.com/j3a1gDO.png

            – Gem
            Aug 26 '16 at 11:40











          • does this right

            – Gem
            Aug 26 '16 at 11:41











          • come to skype...

            – Gem
            Aug 26 '16 at 11:41











          • not working.....

            – Gem
            Aug 27 '16 at 4:43











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f133149%2fhow-can-i-do-cross-sell-products-blocks-on-add-to-cart-popup-box%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Hi You can do that by adding crosssell block html in you ajax response in your controller ajax action.



          $this->loadLayout();
          $block = $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml');
          $response['crosssell'] = $block->toHtml();
          $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));


          Now you can access this response crosssell block html in Ajax success block and can add it in popup html.



          I Hope this will be helpful to you.






          share|improve this answer


























          • @ could to pls join chat, chat.stackexchange.com/rooms/44517/…

            – Gem
            Aug 26 '16 at 8:37











          • chat.stackexchange.com/rooms/44517/…

            – Gem
            Aug 26 '16 at 8:38











          • not working after add your code

            – Gem
            Aug 26 '16 at 11:40











          • i.imgur.com/7LG4oby.png

            – Gem
            Aug 26 '16 at 11:40











          • @JeevaRathinam Sorry for late reply..i have updated answer please check.

            – Hardik Shah
            Aug 26 '16 at 14:08
















          0














          Hi You can do that by adding crosssell block html in you ajax response in your controller ajax action.



          $this->loadLayout();
          $block = $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml');
          $response['crosssell'] = $block->toHtml();
          $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));


          Now you can access this response crosssell block html in Ajax success block and can add it in popup html.



          I Hope this will be helpful to you.






          share|improve this answer


























          • @ could to pls join chat, chat.stackexchange.com/rooms/44517/…

            – Gem
            Aug 26 '16 at 8:37











          • chat.stackexchange.com/rooms/44517/…

            – Gem
            Aug 26 '16 at 8:38











          • not working after add your code

            – Gem
            Aug 26 '16 at 11:40











          • i.imgur.com/7LG4oby.png

            – Gem
            Aug 26 '16 at 11:40











          • @JeevaRathinam Sorry for late reply..i have updated answer please check.

            – Hardik Shah
            Aug 26 '16 at 14:08














          0












          0








          0







          Hi You can do that by adding crosssell block html in you ajax response in your controller ajax action.



          $this->loadLayout();
          $block = $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml');
          $response['crosssell'] = $block->toHtml();
          $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));


          Now you can access this response crosssell block html in Ajax success block and can add it in popup html.



          I Hope this will be helpful to you.






          share|improve this answer















          Hi You can do that by adding crosssell block html in you ajax response in your controller ajax action.



          $this->loadLayout();
          $block = $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml');
          $response['crosssell'] = $block->toHtml();
          $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));


          Now you can access this response crosssell block html in Ajax success block and can add it in popup html.



          I Hope this will be helpful to you.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 26 '16 at 14:07

























          answered Aug 26 '16 at 6:27









          Hardik ShahHardik Shah

          89869




          89869













          • @ could to pls join chat, chat.stackexchange.com/rooms/44517/…

            – Gem
            Aug 26 '16 at 8:37











          • chat.stackexchange.com/rooms/44517/…

            – Gem
            Aug 26 '16 at 8:38











          • not working after add your code

            – Gem
            Aug 26 '16 at 11:40











          • i.imgur.com/7LG4oby.png

            – Gem
            Aug 26 '16 at 11:40











          • @JeevaRathinam Sorry for late reply..i have updated answer please check.

            – Hardik Shah
            Aug 26 '16 at 14:08



















          • @ could to pls join chat, chat.stackexchange.com/rooms/44517/…

            – Gem
            Aug 26 '16 at 8:37











          • chat.stackexchange.com/rooms/44517/…

            – Gem
            Aug 26 '16 at 8:38











          • not working after add your code

            – Gem
            Aug 26 '16 at 11:40











          • i.imgur.com/7LG4oby.png

            – Gem
            Aug 26 '16 at 11:40











          • @JeevaRathinam Sorry for late reply..i have updated answer please check.

            – Hardik Shah
            Aug 26 '16 at 14:08

















          @ could to pls join chat, chat.stackexchange.com/rooms/44517/…

          – Gem
          Aug 26 '16 at 8:37





          @ could to pls join chat, chat.stackexchange.com/rooms/44517/…

          – Gem
          Aug 26 '16 at 8:37













          chat.stackexchange.com/rooms/44517/…

          – Gem
          Aug 26 '16 at 8:38





          chat.stackexchange.com/rooms/44517/…

          – Gem
          Aug 26 '16 at 8:38













          not working after add your code

          – Gem
          Aug 26 '16 at 11:40





          not working after add your code

          – Gem
          Aug 26 '16 at 11:40













          i.imgur.com/7LG4oby.png

          – Gem
          Aug 26 '16 at 11:40





          i.imgur.com/7LG4oby.png

          – Gem
          Aug 26 '16 at 11:40













          @JeevaRathinam Sorry for late reply..i have updated answer please check.

          – Hardik Shah
          Aug 26 '16 at 14:08





          @JeevaRathinam Sorry for late reply..i have updated answer please check.

          – Hardik Shah
          Aug 26 '16 at 14:08













          0














          Write this code in popup area file and you



          {{block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"}}


          Means call crosssell.phtml file in popup window.
          And this is the code for it.



          <?php echo $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml')->toHtml();?>


          And design it as per you need.






          share|improve this answer


























          • i.imgur.com/j3a1gDO.png

            – Gem
            Aug 26 '16 at 11:40











          • does this right

            – Gem
            Aug 26 '16 at 11:41











          • come to skype...

            – Gem
            Aug 26 '16 at 11:41











          • not working.....

            – Gem
            Aug 27 '16 at 4:43
















          0














          Write this code in popup area file and you



          {{block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"}}


          Means call crosssell.phtml file in popup window.
          And this is the code for it.



          <?php echo $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml')->toHtml();?>


          And design it as per you need.






          share|improve this answer


























          • i.imgur.com/j3a1gDO.png

            – Gem
            Aug 26 '16 at 11:40











          • does this right

            – Gem
            Aug 26 '16 at 11:41











          • come to skype...

            – Gem
            Aug 26 '16 at 11:41











          • not working.....

            – Gem
            Aug 27 '16 at 4:43














          0












          0








          0







          Write this code in popup area file and you



          {{block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"}}


          Means call crosssell.phtml file in popup window.
          And this is the code for it.



          <?php echo $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml')->toHtml();?>


          And design it as per you need.






          share|improve this answer















          Write this code in popup area file and you



          {{block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"}}


          Means call crosssell.phtml file in popup window.
          And this is the code for it.



          <?php echo $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml')->toHtml();?>


          And design it as per you need.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 9 '17 at 7:47









          Teja Bhagavan Kollepara

          2,94841847




          2,94841847










          answered Aug 26 '16 at 11:14









          MayurMayur

          64110




          64110













          • i.imgur.com/j3a1gDO.png

            – Gem
            Aug 26 '16 at 11:40











          • does this right

            – Gem
            Aug 26 '16 at 11:41











          • come to skype...

            – Gem
            Aug 26 '16 at 11:41











          • not working.....

            – Gem
            Aug 27 '16 at 4:43



















          • i.imgur.com/j3a1gDO.png

            – Gem
            Aug 26 '16 at 11:40











          • does this right

            – Gem
            Aug 26 '16 at 11:41











          • come to skype...

            – Gem
            Aug 26 '16 at 11:41











          • not working.....

            – Gem
            Aug 27 '16 at 4:43

















          i.imgur.com/j3a1gDO.png

          – Gem
          Aug 26 '16 at 11:40





          i.imgur.com/j3a1gDO.png

          – Gem
          Aug 26 '16 at 11:40













          does this right

          – Gem
          Aug 26 '16 at 11:41





          does this right

          – Gem
          Aug 26 '16 at 11:41













          come to skype...

          – Gem
          Aug 26 '16 at 11:41





          come to skype...

          – Gem
          Aug 26 '16 at 11:41













          not working.....

          – Gem
          Aug 27 '16 at 4:43





          not working.....

          – Gem
          Aug 27 '16 at 4:43


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f133149%2fhow-can-i-do-cross-sell-products-blocks-on-add-to-cart-popup-box%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          what is the purpose of having a “thru cal” on RF PCB?

          What does Gandalf whisper to the Moth on the Orthanc in Isengard?

          magento2 creating a lot of catalogrule_product_temp tables