From 8ba36120fb64c4fc0a0af0b8380c03d37e6f79f4 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 5 Jan 2015 16:02:52 +0100 Subject: [PATCH] Option: Only link configurables with simples from the current file. When the onlycurrentsimples option is set, autolink only works for simple skus that existed in file before the current item. --- .../magmi_configurableprocessor.php | 18 +++++++++++++++++- .../configurables/options_panel.php | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/magmi/plugins/base/itemprocessors/configurables/magmi_configurableprocessor.php b/magmi/plugins/base/itemprocessors/configurables/magmi_configurableprocessor.php index 32d755af..840bbde6 100644 --- a/magmi/plugins/base/itemprocessors/configurables/magmi_configurableprocessor.php +++ b/magmi/plugins/base/itemprocessors/configurables/magmi_configurableprocessor.php @@ -84,6 +84,14 @@ public function autoLink($pid) $this->dolink($pid, "LIKE CONCAT(cpec.sku,'%')"); } + public function autoLinkCurrentSimples($pid, $skulist=array()) + { + if (!empty($skulist)) + { + $this->dolink($pid, "LIKE CONCAT(cpec.sku,'%') AND cpes.sku IN (".$this->arr2values($skulist).")", $skulist); + } + } + public function updSimpleVisibility($pid) { $vis = $this->getParam("CFGR:updsimplevis", 0); @@ -156,6 +164,10 @@ public function getMatchMode($item) { $matchmode = "cursimples"; } + elseif ($this->getParam("CFGR:simplesbeforeconf") == 2) + { + $matchmode = "autocursimples"; + } if (isset($item["simples_skus"]) && trim($item["simples_skus"]) != "") { $matchmode = "fixed"; @@ -169,7 +181,7 @@ public function processItemAfterId(&$item, $params = null) // if item is not configurable, nothing to do if ($item["type"] !== "configurable") { - if ($this->getParam("CFGR:simplesbeforeconf") == 1) + if ($this->getParam("CFGR:simplesbeforeconf") != 0) { $this->_currentsimples[] = $item["sku"]; } @@ -334,6 +346,10 @@ public function processItemAfterId(&$item, $params = null) $this->autoLink($pid); $this->updSimpleVisibility($pid); break; + case "autocursimples": + $this->autoLinkCurrentSimples($pid, $this->_currentsimples); + $this->updSimpleVisibility($pid); + break; case "cursimples": $this->fixedLink($pid, $this->_currentsimples); $this->updSimpleVisibility($pid); diff --git a/magmi/plugins/base/itemprocessors/configurables/options_panel.php b/magmi/plugins/base/itemprocessors/configurables/options_panel.php index d68d0abf..ec6df7be 100755 --- a/magmi/plugins/base/itemprocessors/configurables/options_panel.php +++ b/magmi/plugins/base/itemprocessors/configurables/options_panel.php @@ -21,6 +21,9 @@ +