Reputation: 1223
I'm trying to add an attribute "Collection" to display on the front Office of hybris B2C Accelerator.
So far I have declared the following Beans in my projectName-Spring.xml file:
<alias name="defaultProductSpecialPopulator" alias="productSpecialPopulator" />
<bean id="defaultProductSpecialPopulator" class="de.hybris.electronics.facades.populators.ProductSpecialPopulator" scope="prototype">
<property name="modelService" ref="modelService" />
</bean>
<alias name="defaultProductConfiguredPopulator" alias="productConfiguredPopulator" />
<bean id="defaultProductConfiguredPopulator" class="de.hybris.platform.commercefacades.converter.impl.DefaultConfigurablePopulator">
<property name="populators">
<map key-type="de.hybris.platform.commercefacades.product.ProductOption">
<entry key="SPECIAL" value-ref="productSpecialPopulator" />
</map>
</property>
</bean>
In my ProjectName-core.xml file, I added the attribute collection:
<typegroup name="Product">
<itemtype code="Product" autocreate="false" generate="false">
<description>Pending description...</description>
<attributes>
<attribute qualifier="collection" type="java.lang.String">
<description>Pending description...</description>
<persistence type="property"></persistence>
</attribute>
</attributes>
</itemtype>
</typegroup>
But then, when I implemented the populator, I got the following error:
Bound mismatch: The type TARGET is not a valid substitute for the bounded parameter of the type AbstractProductPopulator
Here's the populator in question:
package de.hybris.electronics.facades.populators;
import de.hybris.electronics.facades.product.data.ProductData;
import de.hybris.platform.commercefacades.product.converters.populator.AbstractProductPopulator;
import de.hybris.platform.core.model.product.ProductModel;
import de.hybris.platform.servicelayer.dto.converter.ConversionException;
public class ProductSpecialPopulator<SOURCE extends ProductModel, TARGET extends ProductData>
extends AbstractProductPopulator<SOURCE, TARGET>
{
@Override
public void populate(final ProductModel source, final ProductData target) throws ConversionException
{
target.setCollection(source.getCollection());
}
}
The error itself is thrown by TARGET in this line:
extends AbstractProductPopulator<SOURCE, TARGET>
And here's the definition of the AbstractProductPopulator:
public abstract class AbstractProductPopulator<SOURCE extends ProductModel, TARGET extends ProductData>
implements Populator<SOURCE, TARGET>
Upvotes: 1
Views: 281
Reputation: 1593
I believe that the problem is caused by the fact that ProductSpecialPopulator uses de.hybris.electronics.facades.product.data.ProductData
and the AbstractProductPopulator most probably uses de.hybris.platform.commercefacades.product.data.ProductData,
therefore these are two different classes(the package is different but the name, i.e ProductData is the same) causing the error.
Most probably there is an extensionName-beans.xml file in which the bean for ProductData is defined like this class="de.hybris.electronics.facades.product.data.ProductData" instead of class="de.hybris.platform.commercefacades.product.data.ProductData", which should be the proper way of adding an attribute to the already existing hybris Product Data
Upvotes: 1