Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:OPEN-DSI/ecommerceng_woosync
Browse files Browse the repository at this point in the history
  • Loading branch information
kkhelifa-opendsi committed Mar 1, 2019
2 parents 70d276a + d79af35 commit c3c0d41
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
3 changes: 3 additions & 0 deletions class/business/eCommerceUtils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public function synchAll($toNb=0)
if ($result >= 0) $result=$synchro->synchSociete($toNb);
if ($result >= 0) $result=$synchro->synchCommande($toNb);
if ($result >= 0) $result=$synchro->synchFacture($toNb);

if ($result >= 0) $result=$synchro->synchDtoECategory($toNb);
if ($result >= 0) $result=$synchro->synchDtoEProduct($toNb);
}

if ($error || $result < 0)
Expand Down
4 changes: 2 additions & 2 deletions class/data/eCommerceCategory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public function fetchByRemoteId($remoteId, $siteId)

if ($resql)
{
if ($this->db->num_rows($resql) == 1)
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);

Expand Down Expand Up @@ -502,7 +502,7 @@ public function fetchByFKCategory($fKCategory, $siteId)

if ($resql)
{
if ($this->db->num_rows($resql) == 1)
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$resCall = $this->fetchByRemoteId($obj->remote_id, $siteId);
Expand Down
28 changes: 22 additions & 6 deletions class/data/woocommerce/eCommerceRemoteAccessWoocommerce.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,7 @@ public function updateRemoteProduct($remote_id, $object)
}
}
if ($productStatusSynchDirection == 'dtoe' || $productStatusSynchDirection == 'all') {
$productData['status'] = (!empty($status) ? $status : '');
$productData['status'] = (!empty($status) ? $status : 'publish');
}

// Synch extrafields <=> metadatas
Expand Down Expand Up @@ -2499,7 +2499,7 @@ public function createRemoteProduct($object)
}
}
if ($productStatusSynchDirection == 'dtoe' || $productStatusSynchDirection == 'all') {
$productData['status'] = (!empty($status) ? $status : '');
$productData['status'] = (!empty($status) ? $status : 'publish');
}

// Synch extrafields <=> metadatas
Expand Down Expand Up @@ -2579,10 +2579,26 @@ public function createRemoteCategories($batch)
if (isset($cats_id_remote_id[$categoryData['parent']])) {
$group[$key]['parent'] = $cats_id_remote_id[$categoryData['parent']]['remote_id'];
} elseif ($categoryData['parent'] > 0) {
$this->errors[] = $langs->trans('ECommerceWoocommerceCreateRemoteCategoryParentNotCreated', $this->site->name, $categoryData['name'], $categoryData['slug']);
dol_syslog(__METHOD__ .
': Error:' . $langs->trans('ECommerceWoocommerceCreateRemoteCategoryParentNotCreated', $this->site->name, $categoryData['name'], $categoryData['slug']), LOG_ERR);
return false;
$sql="SELECT remote_id FROM ".MAIN_DB_PREFIX."ecommerce_category WHERE fk_category =".$categoryData['parent'];
$resql=$this->db->query($sql);
if ($resql) {
if ($this->db->num_rows($resql)==1) {
$obj = $this->db->fetch_object($resql);
$group[$key]['parent'] = $obj->remote_id;
} else {

$this->errors[] = $langs->trans('ECommerceWoocommerceCreateRemoteCategoryParentNotFound', $this->site->name, $categoryData['name'], $categoryData['slug']);
dol_syslog(__METHOD__ .
': Error:' . $langs->trans('ECommerceWoocommerceCreateRemoteCategoryParentNotFound', $this->site->name, $categoryData['name'], $categoryData['slug']), LOG_ERR);
return false;
}
} else {

$this->errors[] = $langs->trans('ECommerceWoocommerceCreateRemoteCategoryParentNotCreated', $this->site->name, $categoryData['name'], $categoryData['slug']);
dol_syslog(__METHOD__ .
': Error:' . $langs->trans('ECommerceWoocommerceCreateRemoteCategoryParentNotCreated', $this->site->name, $categoryData['name'], $categoryData['slug']), LOG_ERR);
return false;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function getVersion()
* @param Conf $conf Objet conf
* @return int <0 if fatal error, 0 si nothing done, >0 if ok
*/
function run_trigger($action,$object,$user,$langs,$conf)
function runTrigger($action,$object,$user,$langs,$conf)
{
$error=0;

Expand Down
4 changes: 2 additions & 2 deletions site.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@
if ($user->rights->ecommerceng->write)
$synchRights = true; // Set permission ok for .tpl

if (count($synchro->success))
if (@count($synchro->success))
$success = $synchro->success;

if (count($synchro->errors))
if (@count($synchro->errors))
$errors = $synchro->errors;
}
catch (Exception $e)
Expand Down

0 comments on commit c3c0d41

Please sign in to comment.