Skip to content

Commit

Permalink
Option: Only link configurables with simples from the current file.
Browse files Browse the repository at this point in the history
When the onlycurrentsimples option is set, autolink only works for
simple skus that existed in file before the current item.
  • Loading branch information
barryvdh committed Jan 5, 2015
1 parent 6a49d8a commit 7109526
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ 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);
Expand Down Expand Up @@ -156,6 +163,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";
Expand All @@ -169,7 +180,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"];
}
Expand Down Expand Up @@ -334,6 +345,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<option value="1"
<?php if ($this->getParam("CFGR:simplesbeforeconf")==1){?>
selected="selected" <?php }?>>Yes</option>
<option value="2"
<?php if ($this->getParam("CFGR:simplesbeforeconf")==2){?>
selected="selected" <?php }?>>Yes, but filter on SKU</option>
</select></li>
</ul>
<ul class="formline">
Expand Down

0 comments on commit 7109526

Please sign in to comment.