Tony,
Thanks! First, just so you know, I am building a module that allows a special attribute RFQ to be assigned to a product. I need to check and see if this attribute is assigned or not, and if so make changes to how the attributes are displayed.
I have looked and see there is no class:
Quote:
Originally Posted by tony_sologubov
\XLite\View\Product\Details\Customer\AttributeValu es class instead of \XLite\View\Product\AttributeValues
|
I think you mean: \XLite\View\Product\Details\Customer\AttributesMod ify
Correct?
Quote:
Originally Posted by tony_sologubov
The reason, why you could not achieve the needed result by removing template is because that template was not assigned into any view list. You can see it if you check the xc_view_lists table in the database.
|
Ah, Thanks! I will check this table in the future.
Quote:
Originally Posted by tony_sologubov
So, the proper way to work around it is to decorate the class as you did, but you also can remove it from view list as well:
\XLite\Core\Layout::getInstance()->removeClassFromLists('\XLite\View\Product\Details \Customer\AttributeValues');
|
Okay, I would like to decorate the class, and remove this template so I can assign my own. I also want to run a boolean test to see if the special attribute is assigned. My current code:
Code:
namespace XLite\Module\Baby\RFQ\View\Product;
/**
* Product attribute values
*/
class AttributeValues extends \XLite\View\Product\AttributeValues implements \XLite\Base\IDecorator
{
/**
* Return widget default template
*
* @return string
*/
protected function getDefaultTemplate()
{
return 'modules/Baby/RFQ/product/details/parts/attributes_modify/body.tpl';
}
/**
* Check if product has an RFQ attribute
*
* @param array $attributes Attributes
*
* @return boolean
*/
protected function isRFQ()
{
$attributeslist = $this->getAttributes();
$foundRFQ = false;
$product = $this->getProduct();
if ($product && !\XLite::isAdminZone()) {
foreach ($attributeslist as $i => $attribute) {
$value = $attribute->getAttributeValue($product);
if (
$value
&& $value instanceOf \XLite\Module\Baby\RFQ\Model\AttributeValue\AttributeValueRFQ
) {
$foundRFQ = true;
}
}
}
return $foundRFQ;
}
}
This works. It removes the default template and assigns my own, and when I use:
Code:
{if:isRFQ()}
Yep its a rfq
{else:}
Nope its not
{end:}
In my modules/baby/RFQ/product/details/parts/attributes_modify/body.tpl then it works correctly.
I tried decorating the class you suggested:
\XLite\View\Product\Details\Customer\AttributesMod ify and using the same code as above but it did not work.
Can you suggest what code I would use in my decorator class to properly override this default template and perform my boolean test?
Once again, thanks. It's great to talk to you man!
