0

I posted a question about adding a step in the regular Magento checkout (not one-step checkout) and I understand now that it is pretty much not possible. I am wondering now if there is a way to always show the same 6 cross-sell products? With the layout I have - it doesn't show them all...Maybe an extension or something? I need to increase my sales by offering additional items (balloons etc.)

EDIT after I've done all the steps posted below: I have created all these folders and files in the specified directories. I have also renamed everything that says: "mycompany" to "AccessShop" (the name of my theme) - is that correct? I uploaded all the files to the paths specified above but I don't see this extra page with cross-sell items anywhere on the front or back-end? Where shall I look for this?

  • you need to write a custom module – Shakir Khan Feb 24 '16 at 6:29
  • somebody please help... – Allysin Jun 8 '16 at 11:06
0

Sorry for late reply may be it's help others

You need to implement your own module to do so

app/code/local/MyCompany/Checkout/Block/Cart in Crosssell.php

class MyCompany_Checkout_Block_Cart_Crosssell extends  Mage_Catalog_Block_Product_Abstract
{

//     /**
//      * Items quantity will be capped to this value
//      *
//      * @var int
//      */
//     protected $_maxItemCount = 100;

//     /**
//      * Get crosssell items
//      *
//      * @return array
//      */

public function getItemCount()
{
     return count($this->getItems());
}

public function getItems()
{
    $items = $this->getData(\'items\');
    if (is_null($items)) {
    $items = array();
    $ninProductIds = $this->_getCartProductIds();
    if ($ninProductIds) {
        $lastAdded = (int) $this->_getLastAddedProductId();
        if ($lastAdded) {
            $collection = $this->_getCollection()
                ->addProductFilter($lastAdded);
            if (!empty($ninProductIds)) {
                $collection->addExcludeProductFilter($ninProductIds);
            }
            $collection->setPositionOrder()->load();

            foreach ($collection as $item) {
                $ninProductIds[] = $item->getId();
                $items[] = $item;
            }
        }

        if (count($items) < 100) {
            $filterProductIds = array_merge($this->_getCartProductIds(), $this->_getCartProductIdsRel());
            $collection = $this->_getCollection()
                ->addProductFilter($filterProductIds)
                ->addExcludeProductFilter($ninProductIds)
                ->setPageSize(100-count($items))
                ->setGroupBy()
                ->setPositionOrder()
                ->load();
            foreach ($collection as $item) {
                $items[] = $item;
            }
        }

    }

    $this->setData(\'items\', $items);
   }
   return $items;
  }
 }

app/code/local/MyCompany/Checkout/etc in config.xml:

<?xml version="1.0"?>
<config>
<modules>
<MyCompany_Checkout>
    <version>1.0</version>
</MyCompany_Checkout>
</modules>
<global>
<blocks>
    <checkout>
            <rewrite>
                <cart_crosssell>MyCompany_Checkout_Block_Cart_Crosssell</cart_crosssell>
            </rewrite>
    </checkout>
    <mycompany_checkout>
        <class>MyCompany_Checkout_Block</class>
    </mycompany_checkout>
</blocks>
</global>

app/etc/modules in MyCompany_Checkout.xml:

<?xml version="1.0"?>
<config>
<modules>
<MyCompany_Checkout>
    <active>true</active>
    <codePool>local</codePool>
</MyCompany_Checkout>
</modules>

app/design/frontend/default/mytheme/layout/ in checkout.xml:

<?xml version="1.0"?>
<reference name="content">
<block type="mycompany_checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"/>
</reference> 

EDIT : To make the value selectable in the backend, you'll want to create:

app/code/local/MyCompany/Checkout/etc in system.xml:

<config>
<tabs>
<mycompany_tab translate="label" module="mycompany">
    <label>MyCompany X-Sell Settings</label>
    <sort_order>100</sort_order>
</mycompany_tab>
</tabs>
<sections>
 <mycompany_section translate="label" module="mycompany">
    <label>Max QTY For Upsell Block</label>
    <tab>mycompany_tab</tab>
    <frontend_type>How many</frontend_type>
    <sort_order>0</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>      
    <groups>
        <mycompany_group translate="label">
            <label>Settings</label>
            <frontend_type>text</frontend_type>
            <sort_order>1</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <fields>
                <mycompany_field>
                    <label>Maximum QTY To Display</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>1</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <comment>This is the maximum number of upsell products to display</comment>                    
                </mycompany_field>
            </fields>                      
        </mycompany_group>
    </groups>              
</mycompany_section>
</sections>    

Add this to your existing app/code/local/MyCompany/Checkout/etc/ in config.xml:

....
<adminhtml>
<acl>
    <resources>
        <admin>
            <children>
                <system>
                    <children>
                        <config>
                            <children>
                                <mycompany_section>
                                    <title>MyCompany - All</title>
                                </mycompany_section>
                            </children>
                        </config>
                    </children>
                </system>
            </children>
        </admin>
    </resources>
</acl>
</adminhtml>

And finally, you'd want to replace app/code/local/MyCompany/Checkout/Block/Cart in Crossell.php:

 protected $_maxItemCount = 100;

 With

 protected $_maxItemCount = Mage::getStoreConfig('mycompany_section/mycompany_group/mycompany_field');

If you'd like to know why the config section works like it works, the best article for reference in my opinion is:

Alan Storm | Custom Magento System Configuration

Good luck!

  • Hello and thank you for helping - let me please ask you this - are these 7 modifications suppose to replace those respective files altogether or just some content within the file? I am having trouble even locating the correct path - for example the first one - app/code/local/MyCompany/Checkout/Block/Cart in Crosssell.php --) I have app/code/local and in there "AccessShop" and "Mage" - if I go into AccessShop - there is no "CHECKOUT" directory just "ThemeOptions" and in "Mage" - I have the "Sales" folder only... – Allysin May 28 '16 at 13:14
  • in the 2nd one - I find the confix.xml file in app/code/local/AccessShop/ThemeOptions/etc/ --> is that correct? and there is some content in that file - what do I need to do with that? – Allysin May 28 '16 at 13:15
  • in "app/etc/modules/" there is nothing even remotely similar to a file named "MyCompany_Checkout.xml" - do I create this one? – Allysin May 28 '16 at 13:19
  • this app/design/frontend/default/mytheme/layout/ I don't have either....I have: "/public_html/app/design/frontend/accessshop/default/layout" but no checkout.xml file there - do I create one? – Allysin May 28 '16 at 13:24
  • I have the "system.xml" file in /public_html/app/code/local/AccessShop/ThemeOptions/etc but again - I have something in that file already... – Allysin May 28 '16 at 13:26

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.