on 08-13-2014 6:50 AM
Hi everybody,
I have a question about product cockpit, as of now, I used validator to intercept a approval status change in product cockpit, it will show a validation message in the Editor Area if fail to meet some requirements.
The message will show when user change the value of approval status using the following method
but it won't show the validation message if user uses to change the approval status.
Both method will result in no change in approval status, which is expected, just I am not sure how to make the validation message shown in both methods.
Hi Tony,
You will have to override the setApprovalStatus() method of the exiting ProductServiceImpl class, you could try something like :
public class MyProductServiceImpl extends ProductServiceImpl
{
private static final Logger log = Logger.getLogger(MyProductServiceImpl.class);
@Override
public void setApprovalStatus(final TypedObject item, final String code)
{
if (item.getObject() instanceof ProductModel
&& UISessionUtils
.getCurrentSession()
.getSystemService()
.checkAttributePermissionOn(item.getType().getCode(), CatalogConstants.Attributes.Product.APPROVALSTATUS,
de.hybris.platform.hmc.jalo.AccessManager.CHANGE))
{
final ItemModel itemModel = (ItemModel) item.getObject();
final Product product = (Product) TypeTools.getModelService().getSource(itemModel);
super.setApprovalStatus(item, code);
final ProductModel productModel = (ProductModel) getModelService().get(product);
getModelService().save(productModel);
}
}
}
Hope that helps.
Cheers, Yves
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.