class ProductDefinitionFacadeImpl implements ProductDefinitionFacade {
	


	@Inject
	private ProductService productService;


	@Autowired
	private PersistableProductDefinitionMapper persistableProductDefinitionMapper;
	
	@Autowired
	private ReadableProductDefinitionMapper readableProductDefinitionMapper;
	
	@Autowired
	private ProductVariantFacade productVariantFacade;

	@Inject
	@Qualifier("img")
	private ImageFilePath imageUtils;

	@Override
	public Long saveProductDefinition(MerchantStore store, PersistableProductDefinition product, Language language) {<FILL_FUNCTION_BODY>}

	@Override
	public void update(Long id, PersistableProductDefinition product, MerchantStore merchant,
			Language language) {
		product.setId(id);
		this.saveProductDefinition(merchant, product, language);
	}

	@Override
	public ReadableProductDefinition getProduct(MerchantStore store, Long id, Language language) {
		Product product = productService.findOne(id, store);
		return readableProductDefinitionMapper.convert(product, store, language);
	}

	@Override
	public ReadableProductDefinition getProductBySku(MerchantStore store, String uniqueCode, Language language) {
		
		Product product = null;
		try {
			product = productService.getBySku(uniqueCode, store, language);
		} catch (ServiceException e) {
			throw new ServiceRuntimeException(e);
		}
		return readableProductDefinitionMapper.convert(product, store, language);

	}

}

		

		Product target = null;
		if (product.getId() != null && product.getId().longValue() > 0) {
			Optional<Product> p = productService.retrieveById(product.getId(), store);
			if(p.isEmpty()) {
				throw new ResourceNotFoundException("Product with id [" + product.getId() + "] not found for store [" + store.getCode() + "]");
			}
			target = p.get();
		} else {
			target = new Product();
		}

		try {
			target = persistableProductDefinitionMapper.merge(product, target, store, language);
				
			productService.saveProduct(target);
			product.setId(target.getId());


			return target.getId();
		} catch (Exception e) {
			throw new ServiceRuntimeException(e);
		}
		
	
<no_super_class>