#68 Product relater deletes unrelated links

v1.0_(example)
open
nobody
None
5
2013-08-21
2013-08-21
Paul Cook
No

The product relater plugin has errors in the SQL queries used to remove links, which cause it to delete links for other SKUs, not only the current SKU. One error is the same as the issue in #31, but applies also to the delete routines; the other is a SQL error when regular expressions are used in bi-directional links.

Patch to fix this:

@@ -20,7 +20,7 @@ class RelatedProducts extends Magmi_ItemProcessor
         $sql="SELECT testid.sku,cpe.sku as esku FROM ".$this->arr2select($rinfo["direct"],"sku")." A
        LEFT JOIN ".$this->tablename("catalog_product_entity")." as cpe ON cpe.sku=testid.sku
        WHERE testid.sku NOT LIKE '%re::%'
-       HAVING esku IS NULL";
+       AND cpe.sku IS NULL";
        $result=$this->selectAll($sql,$rinfo["direct"]);

        $to_delete=array();
@@ -84,7 +84,7 @@ class RelatedProducts extends Magmi_ItemProcessor
                  JOIN ".$this->tablename("catalog_product_link_type")." as cplt ON cplt.code='access
                  JOIN ".$this->tablename("catalog_product_link")." as cpl ON cpl.product_id=cpe.enti
                  JOIN ".$this->tablename("catalog_product_link_attribute_int")." as cplai ON cplai.l
-                 JOIN ".$this->tablename("catalog_product_entity")." as cpe2 ON cpe2.sku!=cpe.sku AN
+                 JOIN ".$this->tablename("catalog_product_entity")." as cpe2 ON cpe2.sku!=cpe.sku AN

                  WHERE cpe.sku=?";
        $this->delete($sql,array_merge($joininfo["data"]["cpe2.sku"],array($item["sku"])));
@@ -103,9 +103,9 @@ class RelatedProducts extends Magmi_ItemProcessor
                  FROM ".$this->tablename("catalog_product_entity")." as cpe
                  JOIN ".$this->tablename("catalog_product_link")." as cpl ON cpl.product_id=cpe.enti
                  JOIN ".$this->tablename("catalog_product_link_attribute_int")." as cplai ON cplai.l
-                 JOIN ".$this->tablename("catalog_product_entity")." as cpe2 ON cpe2.sku!=cpe.sku AN
+                 JOIN ".$this->tablename("catalog_product_entity")." as cpe2 ON cpe2.sku!=cpe.sku AN
                  JOIN ".$this->tablename("catalog_product_link_type")." as cplt ON cplt.code='access
-                 WHERE cpe.sku=? OR $j";
+                 WHERE (cpe.sku=? AND $j2) OR (cpe2.sku=? AND $j)";
        $this->delete($sql,array_merge(array($item["sku"]),$joininfo["data"]["cpe2.sku"],array($item[
        }
  }

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks