@@ -79,6 +79,15 @@ class RuleManager
7979 */
8080 protected $ getCategoryByProduct ;
8181
82+ /**
83+ * @var string[]
84+ */
85+ protected $ productTypes = [
86+ 'grouped ' ,
87+ 'configurable ' ,
88+ 'bundle '
89+ ];
90+
8291 /**
8392 * @param ProductCollectionFactory $productCollectionFactory
8493 * @param CatalogConfig $catalogConfig
@@ -88,6 +97,8 @@ class RuleManager
8897 * @param RuleRepositoryInterface $ruleRepository
8998 * @param StoreManagerInterface $storeManager
9099 * @param \Magefan\AutoRelatedProduct\Model\ActionValidator $ruleValidator
100+ * @param RuleCollectionFactory $ruleCollectionFactory
101+ * @param \Magefan\Community\Api\GetCategoryByProductInterface|null $getCategoryByProduct
91102 */
92103 public function __construct
93104 (
@@ -155,6 +166,27 @@ public function getReletedProductsColletion(RuleInterface $rule, array $params =
155166
156167 if ($ currentProduct ) {
157168 $ this ->_itemCollection ->addFieldToFilter ('entity_id ' , ['neq ' => $ currentProduct ->getId ()]);
169+
170+ $ childIds = [];
171+ $ currentProductType = $ currentProduct ->getTypeId ();
172+
173+ if (in_array ($ currentProductType , $ this ->productTypes )) {
174+ $ productTypeInstance = $ currentProduct ->getTypeInstance ();
175+ $ childrenIds = $ productTypeInstance ->getChildrenIds ($ currentProduct ->getId ());
176+ foreach ($ childrenIds as $ childGroup ) {
177+ foreach ($ childGroup as $ childId ) {
178+ $ childIds [] = $ childId ;
179+ }
180+ }
181+ }
182+
183+ if (!empty ($ childIds )) {
184+ if (!empty ($ params ['skip_ids ' ]) && is_array ($ params ['skip_ids ' ])) {
185+ $ params ['skip_ids ' ] = array_merge ($ params ['skip_ids ' ], $ childIds );
186+ } elseif (empty ($ params ['skip_ids ' ])) {
187+ $ params ['skip_ids ' ] = $ childIds ;
188+ }
189+ }
158190 }
159191
160192 if (!empty ($ params ['skip_ids ' ]) && is_array ($ params ['skip_ids ' ])) {
0 commit comments