Pim-community-dev: [Question] Completeness calculator

Created on 18 Apr 2016  ·  5Comments  ·  Source: akeneo/pim-community-dev

I'm asking a Question

We use PIM 1.4 version in our integration and plan upgrade to 1.5 after some month.

Story
We have custom product entity that adds new relation to product. It is ManyToMany unidirectional relation through join table.

Question
What is the best way to update/overwrite completeness calculator to have ability to add additional product data in its calculations. May be there is something like configuration file. May be there is another best way to do it.

Thanks!

question

All 5 comments

Hello @a2xchip,

Sadly, at the moment, you have to override the CompletenessGenerator. It's sad because it's one of the last place in the PIM where custom attribute types are not handled easily via a registry. We do know we have to rewrite this part, it's on our todo list, but I can't provide you an ETA yet.

This part is quite sensitive and complex. What is the nature of the data you want to calculate the completeness on?

If it's linked to a ProductValue, I suggest you to do exactly the same as what we have done for prices. Take a look at the method prepareCompletePrices. That may be a good start of what you'll need to achieve. You'll also need to override the methods getExtraJoins and getExtraConditions to to join and query on your new table(s).

Don't hesitate to explain more your problem, or to give an example, so we can try to help you better ;)

Hello @jjanvier

Thanks for your fast and full response! I think it gives me good point for start. The data is not linked to product value entity but on product entity.

I added images tab to product edit form and created images (Collection) property linking to fileinfo interface.

manyToMany:
        images:
            targetEntity: Akeneo\Component\FileStorage\Model\FileInfoInterface

P.S.
For export we use EnhanceConnector tuned to export 100% complete products. And I am not sure how to make it sure that 100% complete product has at least one image linked to it.

You have to look at the getMainSqlPart method @a2xchip. This generates the complex SQL query that will fill in the completeness. Maybe it'll work in your case just by overriding the methods getExtraJoins and getExtraConditions that I mentioned before. By overriding those 2 methods, this will add your extra logic to getMainSqlPart.

But it depends of your needs. It depends if you consider your product complete when at least 1 (or 2 or 3 or X) or all images are filled in.

So my advice is to first start to override the 2 methods getExtraJoins and getExtraConditions to understand how the completeness works. If you need more custom logic, checkout what we did for prices.

I hope my explanation will help you ^^
Don't hesitate to come back here if you have some difficulties ;)

@jjanvier Thank you very much I will follow your recommendations :-) I think they will save me a lot of time!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ronn0 picture ronn0  ·  4Comments

pardahlman picture pardahlman  ·  4Comments

Jacky75 picture Jacky75  ·  3Comments

vsilent picture vsilent  ·  3Comments

ronthedrummer picture ronthedrummer  ·  3Comments