use of com.axelor.apps.base.db.ProductVariant in project axelor-open-suite by axelor.
the class ProductServiceImpl method generateProductVariants.
@Override
@Transactional
public void generateProductVariants(Product productModel) throws AxelorException {
List<ProductVariant> productVariantList = this.getProductVariantList(productModel.getProductVariantConfig());
int seq = 1;
List<Product> productVariantsList = productRepo.all().filter("self.parentProduct = ?1", productModel).fetch();
if (productVariantsList != null && !productVariantsList.isEmpty()) {
Integer lastSeq = 0;
for (Product product : productVariantsList) {
Integer productSeq = Integer.parseInt(StringUtils.substringAfterLast(product.getCode(), "-"));
if (productSeq.compareTo(lastSeq) > 0) {
lastSeq = productSeq;
}
}
seq = lastSeq + 1;
}
for (ProductVariant productVariant : productVariantList) {
productVariantRepo.save(productVariant);
productRepo.save(this.createProduct(productModel, productVariant, seq++));
}
}
use of com.axelor.apps.base.db.ProductVariant in project axelor-open-suite by axelor.
the class ProductVariantService method containsProductVariantValue.
private boolean containsProductVariantValue(Product product, ProductVariantValue productVariantValue) {
ProductVariant productVariantFind = product.getProductVariant();
ProductVariantValue productVariantValue1 = productVariantFind.getProductVariantValue1();
ProductVariantValue productVariantValue2 = productVariantFind.getProductVariantValue2();
ProductVariantValue productVariantValue3 = productVariantFind.getProductVariantValue3();
ProductVariantValue productVariantValue4 = productVariantFind.getProductVariantValue4();
if ((productVariantValue1 != null && productVariantValue1.getCode().equals(productVariantValue.getCode()) && productVariantValue1.getProductVariantAttr().getCode().equals(productVariantValue.getProductVariantAttr().getCode())) || (productVariantValue2 != null && productVariantValue2.getCode().equals(productVariantValue.getCode()) && productVariantValue2.getProductVariantAttr().getCode().equals(productVariantValue.getProductVariantAttr().getCode())) || (productVariantValue3 != null && productVariantValue3.getCode().equals(productVariantValue.getCode()) && productVariantValue3.getProductVariantAttr().getCode().equals(productVariantValue.getProductVariantAttr().getCode())) || (productVariantValue4 != null && productVariantValue4.getCode().equals(productVariantValue.getCode()) && productVariantValue4.getProductVariantAttr().getCode().equals(productVariantValue.getProductVariantAttr().getCode()))) {
return true;
}
return false;
}
use of com.axelor.apps.base.db.ProductVariant in project axelor-open-suite by axelor.
the class ProductVariantService method createProductVariant.
public ProductVariant createProductVariant(ProductVariantAttr productVariantAttr1, ProductVariantAttr productVariantAttr2, ProductVariantAttr productVariantAttr3, ProductVariantAttr productVariantAttr4, ProductVariantValue productVariantValue1, ProductVariantValue productVariantValue2, ProductVariantValue productVariantValue3, ProductVariantValue productVariantValue4, boolean usedForStock) {
ProductVariant productVariant = new ProductVariant();
productVariant.setProductVariantAttr1(productVariantAttr1);
productVariant.setProductVariantAttr2(productVariantAttr2);
productVariant.setProductVariantAttr3(productVariantAttr3);
productVariant.setProductVariantAttr4(productVariantAttr4);
productVariant.setProductVariantValue1(productVariantValue1);
productVariant.setProductVariantValue2(productVariantValue2);
productVariant.setProductVariantValue3(productVariantValue3);
productVariant.setProductVariantValue4(productVariantValue4);
productVariant.setUsedForStock(usedForStock);
return productVariant;
}
Aggregations