Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes to localxml and valuetrimmer #346

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions magmi/engines/magmi_productimportengine.php
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ public function createAttributes($pid, &$item, $attmap, $isnew, $itemids)
// if handled value is a "DELETE" or a NULL , which will also be removed
if ($ovalue == '__MAGMI_DELETE__' )
{
$deletes[] = $attid;
$deletes[$store_id][] = $attid;
// do not handle value in insert
$ovalue = null;
}
Expand Down Expand Up @@ -1119,10 +1119,13 @@ public function createAttributes($pid, &$item, $attmap, $isnew, $itemids)
//if we have values to delete
if (!empty($deletes))
{
$sidlist = implode(",", $store_ids);
$attidlist = implode(",", $deletes);
$sql = "DELETE FROM $cpet WHERE entity_type_id=? AND attribute_id IN ($attidlist) AND store_id IN ($sidlist) AND entity_id=?";
$this->delete($sql, array($this->getProductEntityType(),$pid));
foreach ($deletes as $store_id => $to_delete)
{
$sidlist = $store_id;
$attidlist = implode(",", $to_delete);
$sql = "DELETE FROM $cpet WHERE entity_type_id=? AND attribute_id IN ($attidlist) AND store_id IN ($sidlist) AND entity_id=?";
$this->delete($sql, array($this->getProductEntityType(),$pid));
}
}
//if no values inserted or deleted on a new item, we have a problem
if (empty($deletes) && empty($inserts) && $isnew)
Expand Down
4 changes: 2 additions & 2 deletions magmi/inc/magmi_engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,8 @@ public function connectToMagento()
$conn = $this->getProp("DATABASE", "connectivity", "net");
$debug = $this->getProp("DATABASE", "debug",false);
$socket = $this->getProp("DATABASE", "unix_socket");
if ($conn == 'localxml') {
$baseDir = $this->getProp('MAGENTO', 'basedir');
if ($conn == 'localxml')
$baseDir = $this->getMagentoDir();
$xmlPath = $baseDir.'/app/etc/local.xml';
if (!file_exists($xmlPath))
{
Expand Down
30 changes: 16 additions & 14 deletions magmi/plugins/extra/itemprocessors/valuetrim/valuetrimmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,24 @@ public function processItemBeforeId(&$item, $params = null)
$tc = $this->getTrimmableCols($item);
foreach ($tc as $col => $mode)
{
// for select, just trim value
if ($mode == "select")
{
$item[$col] = trim($item[$col]);
}
else
// for multiselect, recompose trimmed value list
{
$sep = Magmi_Config::getInstance()->get("GLOBAL", "mutiselect_sep", ",");
$vt = explode($sep, $item[$col]);
foreach ($vt as &$v)
if (isset($item[$col])) {
// for select, just trim value
if ($mode == "select")
{
$v = trim($v);
$item[$col] = trim($item[$col]);
}
else
// for multiselect, recompose trimmed value list
{
$sep = Magmi_Config::getInstance()->get("GLOBAL", "mutiselect_sep", ",");
$vt = explode($sep, $item[$col]);
foreach ($vt as &$v)
{
$v = trim($v);
}
$item[$col] = implode($sep, $vt);
unset($vt);
}
$item[$col] = implode($sep, $vt);
unset($vt);
}
}
return true;
Expand Down