View Single Post
  #18  
Old 07-30-2014, 06:21 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: All Products on front page, similar to featured products

Hi Michael!

So, here is the instruction how to do this mod:
1) Create an empty module according to http://kb.x-cart.com/display/XDD/How+to+create+a+module

Do not forget to adjust your namespace.

2) In your module add the View/Custom/ProductsOnHome.php file with the following content:

PHP Code:
<?php

namespace XLite\Module\XC\CustomSkin\View\Customer;

/**
 *
 * @ListChild (list="center.bottom", zone="customer", weight="300")
 */

class ProductsOnHome extends \XLite\View\ItemsList\Product\Customer\Category\ACategory
{
    protected 
$allProducts null;

    protected function 
getHead()
    {
        
'My products';
    }

// this method defines that you do not need pagination
    
protected function getPagerClass()
    {
        return 
'\XLite\View\Pager\Infinity';
    }

// this method defines that all products must be displayed in this section
    
protected function getData(\XLite\Core\CommonCell $cnd$countOnly false)
    {
        if (!isset(
$this->allProducts)) {
            
$this->allProducts = \XLite\Core\Database::getRepo('XLite\Model\Product')->findAll();
        }

        return 
true == $countOnly
            
count($this->allProducts)
            : 
$this->allProducts;
    }

// disabling ability to sort products and switch between display modes
    
protected function defineWidgetParams()
    {
        
parent::defineWidgetParams();

        
$this->widgetParams[self::PARAM_GRID_COLUMNS]->setValue(3);

        unset(
$this->widgetParams[self::PARAM_SHOW_DISPLAY_MODE_SELECTOR]);
        unset(
$this->widgetParams[self::PARAM_SHOW_SORT_BY_SELECTOR]);
    }
}

Again, do not forget to adjust your namespaces.

3) Rebuild the cache and you will see the needed results.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote