Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: SystemEvent TYPE_DELETE dont working
I'm using the event to can have the deletes events marked for future export / import data. this is working for one model and for the other one is not working. The only difference is one model has a ModelPortletDataHandler related and the other one dont. Is working for ProductPresentation. This is the one dont have the PortletDataHandler related. Here is the code:
Appreciate any help. Thanks!
***********************ProductLocalServiceImpl class ***********************************************************
/***
* Delete product and relations
* @param productId
* @return
*/
@Override
@Indexable(type = IndexableType.DELETE)
public Product deleteProduct(long productId) throws PortalException {
Product product = getProduct(productId);
deleteProduct(product);
return product;
}
/***
* Delete product and relations
* @param product the product
* @return
*/
@Indexable(type = IndexableType.DELETE)
@Override
@SystemEvent(type = SystemEventConstants.TYPE_DELETE)
public Product deleteProduct(Product product) {
//delete product
super.deleteProduct(product);
//remove product presentations
productPresentationLocalService.deleteByProductId(product.getProductId());
//delete article and successCase products
articleLocalService.clearProductArticles(product.getProductId());
successCaseLocalService.clearProductSuccessCases(product.getProductId());
return product;
}
**************************************** ***********************************************************
***********************ProductPresentationLocalServiceImpl class ***********************************************************
@Override
@Indexable(type = IndexableType.DELETE)
public ProductPresentation deleteProductPresentation(long productPresentationId) throws PortalException {
ProductPresentation productPresentation = getProductPresentation(productPresentationId);
return deleteProductPresentation(productPresentation);
}
@Indexable(type = IndexableType.DELETE)
@Override
@SystemEvent(type = SystemEventConstants.TYPE_DELETE)
public ProductPresentation deleteProductPresentation(ProductPresentation productPresentation) {
return super.deleteProductPresentation(productPresentation);
}
Appreciate any help. Thanks!
***********************ProductLocalServiceImpl class ***********************************************************
/***
* Delete product and relations
* @param productId
* @return
*/
@Override
@Indexable(type = IndexableType.DELETE)
public Product deleteProduct(long productId) throws PortalException {
Product product = getProduct(productId);
deleteProduct(product);
return product;
}
/***
* Delete product and relations
* @param product the product
* @return
*/
@Indexable(type = IndexableType.DELETE)
@Override
@SystemEvent(type = SystemEventConstants.TYPE_DELETE)
public Product deleteProduct(Product product) {
//delete product
super.deleteProduct(product);
//remove product presentations
productPresentationLocalService.deleteByProductId(product.getProductId());
//delete article and successCase products
articleLocalService.clearProductArticles(product.getProductId());
successCaseLocalService.clearProductSuccessCases(product.getProductId());
return product;
}
**************************************** ***********************************************************
***********************ProductPresentationLocalServiceImpl class ***********************************************************
@Override
@Indexable(type = IndexableType.DELETE)
public ProductPresentation deleteProductPresentation(long productPresentationId) throws PortalException {
ProductPresentation productPresentation = getProductPresentation(productPresentationId);
return deleteProductPresentation(productPresentation);
}
@Indexable(type = IndexableType.DELETE)
@Override
@SystemEvent(type = SystemEventConstants.TYPE_DELETE)
public ProductPresentation deleteProductPresentation(ProductPresentation productPresentation) {
return super.deleteProductPresentation(productPresentation);
}
I could fix it. The problem was that I was calling to deleteProduct(Product product) without the interface attribute. The right way is using productLocalService.deleteProduct(Product product) .
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™