akeneo / magento2-connector-community

Akeneo Connector for Magento 2
Open Software License 3.0
82 stars 88 forks source link

Channel filter error importing product models complete only in channel different from default #547

Open daveaie opened 2 years ago

daveaie commented 2 years ago

Environment and configuration - local

  1. Magento 2.4.3 Enterprise Edition - 2.4.3-p1 CE
  2. Akeneo CE 5.0.48 - 5.0.83
  3. Akeneo Connector 102.1.2 - 102.4

Steps to reproduce

It's not easy to have a clear environment of Akeneo and Magento 2 to test it. So I test it in existing environment. I suppose the following steps are exhaustive. (In the next few day I try to reproduce in empty environment). UPDATE test in local environment completed update step below.

Akeneo:

  1. install akeneo base with sample data
  2. Create 2 root categories CatA and CatB and one leaf each ( called a and b)
  3. Create 2 channel channelA and channelB associate respectively catA and catB
  4. use family accessories + set EAN as required only in channelA
  5. Create text attribute _magentowebsite to set Magento website visibility and set and add to family accessories
  6. Create product model HAT with a. at least one complete child (aka set EAN) for channelA c set _magentowebsite to websiteA b. associate to category a under CatA
  7. Use product model model-braided-hat that is just suitable a. one complete child for channelB b. not complete for channelA (aka not set EAN) c. associate to category b under CatB
  8. create API connection

result in channel A image result in channel B image

Magento - Connector config

  1. create websites with one store (in accord with defined locales in Akeneo, 2 are needed to reproduce) a. website A -> store A -> store view A b. website B -> store B -> store view B image

  2. connect to Akeneo

  3. set default channel (Admin Website Channel) to channelA

  4. map websites a. website A -> channelA b. website B -> channelB

image

  1. set product completeness Equals - 100

  2. set product model completeness At least one variant complete image

  3. set website attribute to _magentowebsite image

  4. set other necessary connector settings if needed image image

Now run job to import all data from Akeneo.

Expected result

import both product models and all simple product for any store/channel/lang mapped, that have almost one child complete

  1. exists in Magento Product model HAT and simple producs visible only in website A in CatA.a
  2. exists in Magento Product model model-braided-hat and simple products visible only in website B in CatB.b image

Actual result

Only HAT and all simple are imported in Magento. Product model model-braided-hat was not imported. image

Actual debug result

The Admin Website Channel value is used to filter product model completeness. As you change it to channelB and run import again, then Product model B was correctly imported. After a debug session I make a fix that use 'scope' from filters variable instead of admin website channel config. As soon as possible I will propose a merge request.

Checking advanced log file you can easily see the completeness filters that are wrong assembled:

        (
            [search] => Array
                (
                    [updated] => Array
                        (
                            [0] => Array
                                (
                                    [operator] => >
                                    [value] => 2022-03-09 06:20:12
                                )

                        )

                    [family] => Array
                        (
                            [0] => Array
                                (
                                    [operator] => IN
                                    [value] => Array
                                        (
                                            [0] => accessories
                                        )

                                )

                        )

                    [completeness] => Array
                        (
                            [0] => Array
                                (
                                    [operator] => AT LEAST COMPLETE
                                    [scope] => channelA
                                    [locales] => Array
                                        (
                                            [0] => en_US
                                        )

                                )

                        )

                )

            [scope] => channelA
            [locales] => en_US
        )

   [1] => Array
        (
            [search] => Array
                (
                    [updated] => Array
                        (
                            [0] => Array
                                (
                                    [operator] => >
                                    [value] => 2022-03-09 06:20:12
                                )

                        )

                    [family] => Array
                        (
                            [0] => Array
                                (
                                    [operator] => IN
                                    [value] => Array
                                        (
                                            [0] => accessories
                                        )

                                )

                        )

                    [completeness] => Array
                        (
                            [0] => Array
                                (
                                    [operator] => AT LEAST COMPLETE
                                    [scope] => channelA
                                    [locales] => Array
                                        (
                                            [0] => en_US
                                        )

                                )

                        )

                )

            [scope] => channelB
            [locales] => en_US
        )

)
daveaie commented 2 years ago

Hello again, I test in local env with Akeneo default data and update description with correct data.