Hi Tony,
This is what I have done, however it does not work. It doesn't crash but renders a page with no products selected.
My site has products which have a global attribute called "Vintage" with 2 possible options: "Yes" and "No", to describe if the particular product is considered vintage or not.
What I am trying to do is to create a tab menu "VINTAGE" (target=vintage) to display all products that are Vintage.
1) I followed this tutorial
http://kb.x-cart.com/display/XDD/Creating+new+page
and created this file in <X-Cart>/classes/XLite/Module/MyID/MyModule/Controller/Customer/Vintage.php
PHP Code:
<?php
namespace XLite\Module\MyID\MyModule\Controller\Customer;
class Vintage extends \XLite\Controller\Customer\ACustomer {
}
2) I created XLite\Module\MyID\MyModule\Model\Repo\Product.php
PHP Code:
<?php
namespace XLite\Module\MyID\MyModule\Model\Repo;
class Product extends \XLite\Model\Repo\Product implements \XLite\Base\IDecorator {
protected $name = 'Vintage';
protected $value = 'Yes';
public function findAllVintage() {
return \XLite\Core\Database::getRepo('\XLite\Model\AttributeValue\AttributeValueSelect')
->createQueryBuilder('avs')
->linkInner('avs.attribute', 'a')
->linkInner('a.translations', 'at')
->linkInner('avs.attribute_option', 'ao')
->linkInner('ao.translations', 'aot')
->andWhere('at.name = :attributename AND aot.name = :optionvalue')
->setParameter('attributename', $name)
->setParameter('optionvalue', $value)
->getResult();
}
}
3) I created the viewer class: <X-Cart>/classes/XLite/Module/MyID/MyModule/View/Page/Customer/Vintage.php
PHP Code:
<?php
namespace XLite\Module\MyID/MyModule\View\Page\Customer;
/**
* @ListChild (list="center.bottom", zone="customer", weight="300")
*/
class Vintage extends \XLite\View\ItemsList\Product\Customer\Category\ACategory {
protected $allVintageProducts = null;
protected function getHead() {
return 'Vintage';
}
public static function getAllowedTargets() {
return array_merge(parent::getAllowedTargets(), array('vintage'));
}
protected function getPagerClass() {
return '\XLite\View\Pager\Infinity';
}
protected function getData(\XLite\Core\CommonCell $cnd, $countOnly = false) {
if (!isset($this->allVintageProducts)) {
$this->allVintageProducts = \XLite\Core\Database::getRepo('XLite\Model\Product')->findAllVintage();
}
return true == $countOnly
? count($this->allVintageProducts)
: $this->allVintageProducts;
}
// disabling ability to sort products and switch between display modes
protected function defineWidgetParams()
{
parent::defineWidgetParams();
$this->widgetParams[self::PARAM_SHOW_SORT_BY_SELECTOR]->setValue(false)
}
}
Any idea what am I doing wrong?
Thanks