Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

How eliminate the display options and sorting tabs in product pages

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 12-10-2014, 07:42 PM
 
juancho juancho is offline
 

Advanced Member
  
Join Date: Mar 2014
Posts: 47
 

Default How eliminate the display options and sorting tabs in product pages

Hi

I am trying to get rid of the sorting menu options, and the display menu options (grid, table, list) in product pages. Also I would want to eliminate the pagination. I am using this code but I can't get it to work.

PHP Code:
<?php
 
namespace XLite\Module\MyID\MyModule\View\ItemsList\Product\Customer;

abstract class 
ACustomer extends \XLite\View\ItemsList\Product\Customer\ACustomer implements \XLite\Base\IDecorator
{
    
    protected function 
getPagerClass() 
    { 
        return 
'\XLite\View\Pager\Infinity'
    } 
  

    protected function 
defineWidgetParams()
    {
      
parent::defineWidgetParams(); 

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

Anyone knows what may be wrong?
Thanks
__________________
X-Cart Business 5.0.12
Reply With Quote
  #2  
Old 12-11-2014, 03:34 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

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

Default Re: How eliminate the display options and sorting tabs in product pages

Hi juancho!

1) You should decorate the \XLite\View\ItemsList\Product\Customer\Category\AC ategory class instead of \XLite\View\ItemsList\Product\Customer\ACustomer, because \XLite\View\ItemsList\Product\Customer\ACustomer class is for more widgets than just displaying products in central area.

2)
PHP Code:
protected function getPagerClass() 
    { 
        return 
'\XLite\View\Pager\Infinity'
    } 

This code is correct in order to disable pagination.

3)
PHP Code:
protected function defineWidgetParams()
    {
      
parent::defineWidgetParams(); 

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

This code is almost correct. Instead of
PHP Code:
unset($this->widgetParams[self::PARAM_SHOW_DISPLAY_MODE_SELECTOR]); 
construction you should use this one:

PHP Code:
$this->widgetParams[self::PARAM_SHOW_SORT_BY_SELECTOR]->setValue(false); 

And it will work out.

The corrected mod is here https://dl.dropboxusercontent.com/u/23858825/MyID-MyModule-v5_1_0.tar
__________________
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

The following user thanks tony_sologubov for this useful post:
juancho (12-11-2014)
  #3  
Old 12-11-2014, 03:22 PM
 
juancho juancho is offline
 

Advanced Member
  
Join Date: Mar 2014
Posts: 47
 

Default Re: How eliminate the display options and sorting tabs in product pages

Hi Tony and many thanks.

It works awesome in category pages. However, in "Coming soon", "New arrivals" and "Sale" pages the display menu is still visible.

Do you know how can I fix it?
__________________
X-Cart Business 5.0.12
Reply With Quote
  #4  
Old 12-15-2014, 12:22 PM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

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

Default Re: How eliminate the display options and sorting tabs in product pages

Since the 'view modes' selector is already disabled there and you need only to define another page class (infinity), you can decorate the \XLite\Module\CDev\ProductAdvisor\View\AComingSoon class.

Please, let me know if it works for you.
__________________
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

The following user thanks tony_sologubov for this useful post:
juancho (12-16-2014)
  #5  
Old 12-16-2014, 07:18 PM
 
juancho juancho is offline
 

Advanced Member
  
Join Date: Mar 2014
Posts: 47
 

Default Re: How eliminate the display options and sorting tabs in product pages

Hi Tony,
It did work as you suggested. Thanks!

I have a general question. What is the best way to "decorate" a class? What I am doing is using the methods removeClassFromList to remove the class that I want to decorate, and addClassToList to add my version of the class. Is this the correct approach? Seems a little bit awkward.

Thanks again
__________________
X-Cart Business 5.0.12
Reply With Quote
  #6  
Old 12-17-2014, 01:52 PM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

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

Default Re: How eliminate the display options and sorting tabs in product pages

Quote:
Originally Posted by juancho
Hi Tony,
It did work as you suggested. Thanks!

I have a general question. What is the best way to "decorate" a class? What I am doing is using the methods removeClassFromList to remove the class that I want to decorate, and addClassToList to add my version of the class. Is this the correct approach? Seems a little bit awkward.

Thanks again

Well, you should just decorate the class as described here: http://kb.x-cart.com/display/XDD/Step+3+-+applying+logic+changes

If we are talking about changing viewer classes, then you just need to decorate the class in your module and the changes will be applied after store re-deployment without having to call removeClassFromList() and addClassToList() methods.
__________________
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
  #7  
Old 12-17-2014, 06:46 PM
 
juancho juancho is offline
 

Advanced Member
  
Join Date: Mar 2014
Posts: 47
 

Default Re: How eliminate the display options and sorting tabs in product pages

Hi Tony,
thanks, here I am again, trying to make this run.
ok this is my whole code. It crashes with this message: "Error (code: 1): Call to a member function setValue() on a non-object"

PHP Code:
<?php 

namespace  XLite\Module\MyID\MyModule\View\Custom

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

class ProductsOnHomePage extends \XLite\View\ItemsList\Product\Customer\Category\ACategory 

    protected 
$allProducts null

    protected function 
getHead() 
    { 
        
'My products'
    } 

// this method defines that products will be displayed only in the main page 
    
public static function getAllowedTargets()  
    {  
        
$return = array('main'); 

        return 
$return;  
    }  

// 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(); 
  
//          $this->allProducts = \XLite\Core\Database::getRepo('XLite\Model\Product')->findAllActive(); 
        


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


    public function 
setWidgetParams(array $params)
    {
        
parent::setWidgetParams($params);
        
$this->widgetParams[self::PARAM_SHOW_DISPLAY_MODE_SELECTOR]->setValue(false);
    } 
}

What I am trying to do is get rid of the display menu but maintaining the sort menu.
what it's wrong?
Thanks
__________________
X-Cart Business 5.0.12
Reply With Quote
  #8  
Old 12-17-2014, 08:55 PM
 
juancho juancho is offline
 

Advanced Member
  
Join Date: Mar 2014
Posts: 47
 

Default Re: How eliminate the display options and sorting tabs in product pages

An addition to my previous email:

when I run just this code:

PHP Code:
<?php 

namespace  XLite\Module\Astur\SirtoliSkin\View\Custom

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

class ProductsOnHomePage extends \XLite\View\ItemsList\Product\Customer\Category\ACategory 

    protected 
$allProducts null

    protected function 
getHead() 
    { 
        
'My products'
    } 

// this method defines that products will be displayed only in the main page 
    
public static function getAllowedTargets()  
    {  
        
$return = array('main'); 

        return 
$return;  
    }  

// 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
    } 

}

both, the display and sort menu are visible but when you try to use them by changing to a different option then no product at all is displayed.
__________________
X-Cart Business 5.0.12
Reply With Quote
  #9  
Old 12-18-2014, 03:58 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

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

Default Re: How eliminate the display options and sorting tabs in product pages

Not sure why it does not work for you, because it work perfectly for me:
http://awesomescreenshot.com/0854235ua8

What I have done is I enabled Custom Skin module and then put View/ProductsOnHomePage.php file inside it with this code:

PHP Code:
<?php  

namespace XLite\Module\XC\CustomSkin\View;  

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

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

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

// this method defines that products will be displayed only in the main page  
    
public static function getAllowedTargets()   
    {   
        
$return = array('main');  

        return 
$return;   
    }   

// 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();  
  
//          $this->allProducts = \XLite\Core\Database::getRepo('XLite\Model\Product')->findAllActive();  
        
}  

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


    public function 
setWidgetParams(array $params
    { 
        
parent::setWidgetParams($params); 
        
$this->widgetParams[self::PARAM_SHOW_DISPLAY_MODE_SELECTOR]->setValue(false); 
    }  
}

In order to debug the problem, you need to check that you have not decorated the \XLite\View\ItemsList\Product\Customer\Category\AC ategory class anywhere else. If you did, you might have unsetted $this->widgetParams[self::PARAM_SHOW_DISPLAY_MODE_SELECTOR] param there and it causes the fatal error.
__________________
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

The following user thanks tony_sologubov for this useful post:
juancho (12-18-2014)
  #10  
Old 12-18-2014, 07:05 PM
 
juancho juancho is offline
 

Advanced Member
  
Join Date: Mar 2014
Posts: 47
 

Default Re: How eliminate the display options and sorting tabs in product pages

Hi Tony,
thanks for your previous message.

Have you tried to used the sorting tabs? for instance, have you tried to click on "newest first" or "price" because, in my case the sorting options are also displayed correctly, but when I try to use a different sorting option, such as "price", is when it crashes and does not display any product.
__________________
X-Cart Business 5.0.12
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:16 PM.

   

 
X-Cart forums © 2001-2020