X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   All Products on front page, similar to featured products (https://forum.x-cart.com/showthread.php?t=69469)

tony_sologubov 07-14-2014 05:52 AM

Re: All Products on front page, similar to featured products
 
1) Shall we remove current Featured Products section from front-end or we should simply populate it with the products you need?
2) How these products should be sorted in new section?

minfinger 07-14-2014 06:35 AM

Re: All Products on front page, similar to featured products
 
1. Yes.
2. By product name, as its the name of the puppy.

tony_sologubov 07-16-2014 12:12 PM

Re: All Products on front page, similar to featured products
 
Sorry, I did not quite get the answer to the first question. Would you prefer option 1 (remove current featured products section) or option 2 (populate it with all products)?

Anyway, I will prepare code samples during next week and will post them here.

minfinger 07-19-2014 10:10 AM

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

I see what you're asking now. I do not need the Featured Products Section at all, I only want the front page to be populate with all products and sorted by product name.

I really appreciate your help.

tony_sologubov 07-21-2014 04:45 AM

Re: All Products on front page, similar to featured products
 
Ok, thank you. I will post code samples within couple of weeks.

minfinger 07-21-2014 06:09 AM

Re: All Products on front page, similar to featured products
 
As I'm sure you're busy with other projects, I'm willing to pay for this to happen much sooner.

tony_sologubov 07-23-2014 06:22 AM

Re: All Products on front page, similar to featured products
 
Oh, that is a good option as well :)

tony_sologubov 07-30-2014 06:21 AM

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.

minfinger 07-30-2014 10:23 AM

Re: All Products on front page, similar to featured products
 
This one won't enable either.

tony_sologubov 08-01-2014 01:59 AM

Re: All Products on front page, similar to featured products
 
Please make sure that you have Main.php file in your module, not main.php that starts with small letter.


All times are GMT -8. The time now is 06:43 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.