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

Moving Related Products to a tab

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 02-10-2017, 07:44 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default Moving Related Products to a tab

I can't seem to get this working.

Creating the tab is easy enough and works...

Code:
namespace XLite\Module\Client\ClientTabRelatedProducts\View; abstract class DefineTabFindUpsells extends \XLite\View\Product\Details\Customer\Page\APage implements \XLite\Base\IDecorator { /** * Define tabs * * @return array */ protected function defineTabs() { $list = parent::defineTabs(); $tmp = $this->getData(); if ($tmp>0) { $list['Related Products'] = array( 'list' => 'product.details.page.tab.related', ); } return $list; } /** * Get currently viewed product ID * * @return integer */ protected function getProductId() { return intval(\XLite\Core\Request::getInstance()->product_id); } protected function getSearchConditionFirst() { return new \XLite\Core\CommonCell(); } /** * Return params list to use for search * * @return \XLite\Core\CommonCell */ protected function getSearchCondition() { $cnd = $this->getSearchConditionFirst(); $cnd->{\XLite\Module\XC\Upselling\Model\Repo\UpsellingProduct::SEARCH_PARENT_PRODUCT_ID} = $this->getProductId(); return $cnd; } /** * Return products list - tweaked - just need to find if there are related products and then show tab * * @param \XLite\Core\CommonCell $cnd Search condition * @param boolean $countOnly Return items list or only its size OPTIONAL * * @return mixed */ protected function getData() { if (!isset($this->upsellingProducts) && $this->checkTarget()) { $cnd = $this->getSearchCondition(); $cnd->{\XLite\Module\XC\Upselling\Model\Repo\UpsellingProduct::SEARCH_PARENT_PRODUCT_ID} = $this->getProductId(); $products = array(); $up = \XLite\Core\Database::getRepo('XLite\Module\XC\Upselling\Model\UpsellingProduct') ->search($cnd, false); foreach ($up as $product) { $products[] = $product->getProduct(); } $this->upsellingProducts = $products; } return count($this->upsellingProducts); } }

The above shows an extra tab when there are related products available.

But I can't seem to move the Related Products area to my new tab.

Code:
{## # Product details tab # # # @ListChild(list="product.details.page.tab.related") #} {{ widget_list('itemsList.product.cart') }} <div class="products"> {% if this.getPageData() %} <div class="products-list"> ...
Does work as the getPageData method can't be found.

How do I do this?
__________________
Core version: 5.5.xx
Reply With Quote
  #2  
Old 02-16-2017, 11:13 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default Re: Moving Related Products to a tab

I got it working by adding this to main.php in my tab creating module.

Code:
/** * @return array */ protected static function moveClassesInLists() { if (static::isModuleEnabled('XC\Upselling')) { $classes_list['XLite\Module\XC\Upselling\View\ItemsList\UpsellingProducts'] = [ static::TO_DELETE => [ ['center.bottom', \XLite\Model\ViewList::INTERFACE_CUSTOMER], ], static::TO_ADD => [ ['product.details.page.tab.related', 100, \XLite\Model\ViewList::INTERFACE_CUSTOMER], ], ]; } return $classes_list; } /** * Determines if some module is enabled * * @return boolean */ public static function isModuleEnabled($name) { return \XLite\Core\Database::getRepo('XLite\Model\Module')->isModuleEnabled($name); }
__________________
Core version: 5.5.xx
Reply With Quote

The following user thanks xgarb for this useful post:
qualiteam (02-24-2017)
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



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 12:14 AM.

   

 
X-Cart forums © 2001-2020