-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Problem:
Grouped child products have not the correct group code and are missing on the website search.
When you export a lot of products where you have configurables and simple childs. When not in the same export batch products are not properly related with group_code
Step to reproduce
- Add 1 configurable product with 2 child products.
- Set product export batch size to 2.
- Run export
One product simple will have a group code the other will not. Or both simples do not depending on sort.
Working:
Both simple and configurable products exist in te same batch
Failing:
Configurable and related simple products are in different batches.
Quick fix
Update batch size to the number of products you are exporting
Permanent fix
Make group functionality working across batches. Do not make simple group code dependable on configurable in the same batch.
Fix for this specific problem:
diff --git a/Model/Write/Products/ExportEntity.php b/Model/Write/Products/ExportEntity.php
index 0950f42..0acf18a 100644
--- a/Model/Write/Products/ExportEntity.php
+++ b/Model/Write/Products/ExportEntity.php
@@ -250,6 +250,15 @@ class ExportEntity
*/
public function getGroupCode(): int
{
+ if ($this->groupCode === 0) {
+ try {
+ $groupCode = (int)$this->getAttribute('parent_id', false);
+ $this->groupCode = $groupCode;
+ } catch (\Exception $e) {
+ // ignore, all is lost
+ }
+ }
+
return (int)$this->helper->getTweakwiseId(
$this->getStore()->getId(),
$this->groupCode ? $this->groupCode : $this->getId()