0
Magento 1.9.1
Porto theme

Up-selling is the name of the game now (would you like to super-size that?) and that is the goal here...This is by far the most important issue for us right now. I will start a bounty on this as soon as possible.

The idea is to have a custom page come up with up-sell products (balloons, teddy bears ect.) /I'm using the word UP-SELL in a business sense here rather than Magento lingo/ I have created a custom page already that comes up after the product page that shows cross-sell products specific to that main product. I followed this to get that done:

How to add a custom page with cross-sell products

The problem is that we have some 2000 products and we would prefer to have the same cross-sell/up sell products for all of them. For example now we have things left over from Christmas sales that we need to push and if we needed to add them to the cross-sell page, we would have to modify the cross-sell products in each of the 2000 products.

How to make it so that the custom page shows all the same cross-sell products for all products? Even just displaying products from a specific category on there would work I guess.

Ideally, it would look like this:

enter image description here


Updated on January 12th:

I believe that the featured "institute" is already defined and setup within the Porto theme. I found this code which suppose to make it appear on a page:

 <div class="tab-content" id="tab_featured_contents">
                <div id="featured_product" class="hide-addtolinks move-action">
                    {{block type="filterproducts/featured_home_list" name="featured_list" product_count="12" column_count="4" template="filterproducts/grid.phtml"}}
                </div>
            </div>

But when I try to add this to the IndexController.php:

{{block type="filterproducts/featured_home_list" name="featured_list" product_count="12" column_count="4" template="filterproducts/grid.phtml"}}

It gives the following Error:

The www.mySITE.com page isn’t working

www.mySITE.com is currently unable to handle this request.
500

Updated on January 13th:

I am starting a bounty on this topic. I need help figuring out a specific way to do this. I also need to style it in a way similar to the ProFlowers picture posted here...


Updated on January 23rd, 2018:

I tried to follow the steps outlined by Pedram Behroozi as follows:

  1. Create a new category from: Catalog > Manage Categories. Remember its ID.

Done. Category name is upsells and category ID = 216

2. Add your favorite products to this category.

Done

3. Create the CMS page from: CMS > Pages.

Done. URL Key = addonsales Question: Where is this CMS page called from?

4. Go to the new CMS page's Content tab.

Done

5. Add this line of code in the editor:

{{block type="filterproducts/featured_home_list" name="featured_list" column_count="4" category_id="216" template="filterproducts/grid.phtml"}}

6. Go to the products you've added to the category. Set their Is Features attribute to Yes. 

Done

Then Pedram Behroozi says: I think setting the category_id is necessary, because maybe you have some featured products you don't want to display in this particular page. If you don't want to set Is Featured every time you want to display products you have to create an extension in this fashion:

I have NO featured products I wouldn't want to display in this particular page.

  1. and 8. Does that mean I don't have to implement the next 2 grey blocks of code? (I don't really want to have to create the "extension")

    1. Also note that you should comment ->addAttributeToFilter(array(array('attribute' => 'featured', 'eq' => '1'))) so that you don't have to set Is Featured to Yes.

Does that mean I can un-comment those lines?

10. Now in step 5 of steps above change the code so it looks like this:

{{block type="your_extension/list" name="upsell_list" column_count="4" category_id="[CATEGORY-ID]" template="filterproducts/grid.phtml"}}

Do I need to do this if I'm OK with always setting Featured = YES and then I don't need to make an extension I guess?

Here is where I don't understand how how this works:

I have created an extra page in the check-out using this:

https://github.com/tmhub/suggestpage

as explained here:

How to add a custom page with cross-sell products

This page currently shows the cross-sell products that are defined in each main product via the IndexController.php file that currently looks like this:

<?php

class TM_SuggestPage_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()

{
 $this->loadLayout()
    ->_initLayoutMessages('checkout/session')
    ->_initLayoutMessages('catalog/session');

$block2 = $this->getLayout()->createBlock('checkout/cart_coupon')->setTemplate('checkout/cart/coupon.phtml');
$this->getLayout()->getBlock('content')->append($block2);

$_product = Mage::getModel('catalog/product')->load(100);
$block = $this->getLayout()->createBlock('checkout/cart_crosssell')->setProduct($_product)->setTemplate('checkout/cart/crosssell.phtml'); $this->getLayout()->getBlock('content')->append($block);

$this->renderLayout();
    }
}

How do I change that code to show the global cross-sell/up-sell products that are featured and/or from a category?

-----------------------------------------------------------------------------

Second update on January 23rd, 2018:

As per mskhan's post I:

A. Created a new Static block called upsells with the following code inside:

{{block type="filterproducts/featured_home_list" name="featured_list" product_count="12" column_count="4" template="filterproducts/grid.phtml"}}

B. Then I modified my IndexController.php file to show this:

<?php

class TM_SuggestPage_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
{

 $this->loadLayout()
    ->_initLayoutMessages('checkout/session')
    ->_initLayoutMessages('catalog/session');

$block2 = $this->getLayout()->createBlock('checkout/cart_coupon')->setTemplate('checkout/cart/coupon.phtml');
$this->getLayout()->getBlock('content')->append($block2);

$_product = Mage::getModel('catalog/product')->load(100);
$block = $this->getLayout()->createBlock('cms/block')->setBlockId('upsells')->toHtml();

$this->renderLayout();
    }
}

The good news is - it doesn't show any Errors but the bad news is - it doesn't show any Featured/up-sell products either! Any idea what may be wrong with this setup?

-----------------------------------------------------------------------------

Edited on January 26th: This has not been resolved! I ended up rewarding the bounty to a person with the longest answer but the products are not showing up on the extra page. I will ask this same thing in another question (this post no longer allows me to start new bounties).

14
  • if the products you want to set as cross-sell are not much, you can create an attribute (yes/no type) for them ( you can mass update them) and can filter product collection based on that
    – Piyush
    Jan 11, 2018 at 13:41
  • @Piyush There aren't many - maybe 12 altogether. How do you mean to create a yes/no attribute and then filter product collection based on that?
    – Allysin
    Jan 11, 2018 at 13:43
  • just same as Magento set featured products, create an attribute of yes/no type, assign yes value to those 12 products and then on your custom page get all products having that attribute value 1
    – Piyush
    Jan 11, 2018 at 13:44
  • @Piyush now you gave me an idea! We don't use "Featured products" at all! Would it be possible to set these up-sell/cross-sell products as FEATURED products and then display Featured products on the custom page?
    – Allysin
    Jan 11, 2018 at 13:47
  • yes it is possible (if you have not deleted featured attribute)
    – Piyush
    Jan 11, 2018 at 13:49

3 Answers 3

1
+100

You should add all those products in a category, set their Is Featured attribute to Yes and display them in your CMS page. Follow these steps:

  1. Create a new category from: Catalog > Manage Categories. Remember its ID.
  2. Add your favorite products to this category.

  3. Create the CMS page from: CMS > Pages.

  4. Go to the new CMS page's Content tab.
  5. Add this line of code in the editor:

    {{block type="filterproducts/featured_home_list" name="featured_list" column_count="4" category_id="[CATEGORY-ID]" template="filterproducts/grid.phtml"}}
    
  6. Go to the products you've added to the category. Set their Is Features attribute to Yes. This attribute's code is featured.

I think setting the category_id is necessary, because maybe you have some featured products you don't want to display in this particular page.

If you don't want to set Is Featured every time you want to display products you have to create an extension in this fashion:

# File: etc/config.xml
...
<global>
    <blocks>
        <your_extension>
            <class>Your_Extension_Block</class>
        </your_extension>
    </blocks>
</global>
...

Then create your block (NOTE what it's extending):

class Your_Extension_Block_List extends Smartwave_Filterproducts_Block_Featured_Home_List
{
    protected function _getProductCollection() {
        $storeId    = Mage::app()->getStore()->getId();

        $category_id = $this->getCategoryId();
        $products = Mage::getResourceModel('catalog/product_collection');
        if($category_id) {
            $category = Mage::getModel('catalog/category')->load($category_id);    

            $products = $this->_addProductAttributesAndPrices($products)
                ->addCategoryFilter($category)
                /*###->addAttributeToFilter(array(array('attribute' => 'featured', 'eq' => '1')))*/
                ->setStoreId($storeId)
                ->addStoreFilter($storeId);
        }
        else {
            $products = $this->_addProductAttributesAndPrices($products)
                /*###->addAttributeToFilter(array(array('attribute' => 'featured', 'eq' => '1')))*/
                ->setStoreId($storeId)
                ->addStoreFilter($storeId);
        }

        $products->getSelect()->order(new Zend_Db_Expr("RAND()"));
        $product_count = $this->getProductCount();

        if($product_count)
        {
            $products->setPageSize($product_count);
        }

        Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
        Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
        $store = Mage::app()->getStore();
        $code  = $store->getCode();
        if(!Mage::getStoreConfig("cataloginventory/options/show_out_of_stock", $code))
            Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($products); 

        $this->_productCollection = $products;

        return $this->_productCollection;
    }
}

Also note that you should comment ->addAttributeToFilter(array(array('attribute' => 'featured', 'eq' => '1'))) so that you don't have to set Is Featured to Yes.

Now in step 5 of steps above change the code so it looks like this:

{{block type="your_extension/list" name="upsell_list" column_count="4" category_id="[CATEGORY-ID]" template="filterproducts/grid.phtml"}}

Also you can change template to another phtml file so your products would display in whatever way you want.

11
  • I followed all the steps but it doesn't show anywhere....where do the upsell/crossell products suppose to show up at? Thank you.
    – Allysin
    Jan 21, 2018 at 17:18
  • I am going to award the bounty to you even-though I was not able to make your solution work. Steps 1 - 6 are easy but I am not certain what you mean by "Then create your block" ....do you mean to create a block in CMS - STATIC BLOCKS or put that code into my IndexController.php file? How do I find out what the "Your_Extension_Block" and "Your_Extension_Block_List" is? Thanks again! ;-)
    – Allysin
    Jan 21, 2018 at 21:04
  • If you have problem displaying the products on the steps above, go to System > Permissions > Blocks and allow filterproducts/featured_home_list. Jan 22, 2018 at 5:40
  • You should be familiar with creating an extension in order to create the block Your_Extension_Block_List. Explaining all the steps to create the extension is beyond here. I suggest reading Alan Storm's articles (alanstorm.com/category/magento) or consult a developer. Jan 22, 2018 at 5:51
  • What extension are we talking about here? Is this the "SuggestPage" extension that I have installed from here: magento.stackexchange.com/questions/122348/… that creates the extra step in check-out and allows me to display products on there? The current display of the cross-sell products changed from 5 to 9 and it shows most of the actual cross/up-sells I want to display. This happened after I followed most of the steps in your post and is now global for all the main products (they ALL now show the same 9 cross/up-sells)..
    – Allysin
    Jan 22, 2018 at 11:48
0

Try adding this

{{block type="filterproducts/featured_home_list" name="featured_list" product_count="12" column_count="4" template="filterproducts/grid.phtml"}}

to a cms static block and call that block from within your controller.

Porto theme already have featured attribute on product level. Set it to yes on all the products you want to show on that custom page.

5
  • This sounds great! :o) I made a new static block. Block Title = test; Identifier = test; How do I call that block from within the controller?
    – Allysin
    Jan 21, 2018 at 15:54
  • Refer to this ticket for more details on how to call static block inside your controller magento.stackexchange.com/questions/103779/…
    – mskhan
    Jan 22, 2018 at 6:56
  • Thank you so much for your suggestion. I tried implementing it and I put my end result in "Second update on January 23rd, 2018:" up in my original post. Would you please look at it? Thank you! :)
    – Allysin
    Jan 23, 2018 at 13:38
  • you are not assigning $block2 to the content as you did with $block. Try assigning $block2 to the content. Also, if it doesn't work...try to assign $block2 = $this->getLayout()->createBlock('filterproducts/featured_home_list')->setTemplate('filterproducts/grid.phtml');
    – mskhan
    Jan 24, 2018 at 12:01
  • Thank you for helping. I tried that and it gives the following Error: The www.mysite.com page isn’t working www.mysite.com is currently unable to handle this request. 500
    – Allysin
    Jan 26, 2018 at 0:14
0

If the list of Cross sell products are not going to change very often, then you can hard code the list of SKUs inside the .phtml file.

Updated Answer

Enable Template hints in the admin panel and find out the .phtml file which is reponsible for that page. In that file you can declare a variable like this $productSkus = array('sku1', 'sku2', 'sku3', ....);. Then you can loop over this array using foreach and print the data as per your need. Sample code below:

foreach($productSkus as $sku) {
    $productId = Mage::getModel('catalog/product')->getIdBySku($sku);
    $product = Mage::getModel('catalog/product')->load($productId);
}
2
  • Thank you Karhic. How would you go about doing this?
    – Allysin
    Jan 21, 2018 at 16:02
  • @Allysin I have updated my answer. Jan 22, 2018 at 5:30

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.