// Some fix + multistore for import tools
This commit is contained in:
@@ -125,4 +125,17 @@ class GroupShopCore extends ObjectModel
|
||||
FROM '._DB_PREFIX_.'shop s
|
||||
WHERE id_group_shop='.(int)$this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a group shop ID from group shop name
|
||||
*
|
||||
* @param string $name
|
||||
* @return int
|
||||
*/
|
||||
public static function getIdByName($name)
|
||||
{
|
||||
$sql = 'SELECT id_group_shop FROM '._DB_PREFIX_.'group_shop
|
||||
WHERE name = \''.pSQL($name).'\'';
|
||||
return (int)Db::getInstance()->getValue($sql);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,13 +237,13 @@ abstract class ObjectModelCore
|
||||
}
|
||||
}
|
||||
|
||||
if(!Tools::isMultishopActivated())
|
||||
if (!Tools::isMultishopActivated())
|
||||
{
|
||||
if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'shop')
|
||||
$result &= $this->associateTo(array((int)Shop::getCurrentShop(true)), 'shop');
|
||||
$result &= $this->associateTo(Shop::getCurrentShop(true), 'shop');
|
||||
$assos = GroupShop::getAssoTables();
|
||||
if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'group_shop')
|
||||
$result &= $this->associateTo(array((int)Shop::getCurrentGroupShop()), 'group_shop');
|
||||
$result &= $this->associateTo(Shop::getCurrentGroupShop(), 'group_shop');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -363,6 +363,14 @@ class ProductCore extends ObjectModel
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function add($autodate = true, $nullValues = false)
|
||||
{
|
||||
if (!parent::add($autodate, $nullValues))
|
||||
return false;
|
||||
$this->setStock($this->quantity);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check then return multilingual fields for database interaction
|
||||
|
||||
+19
-3
@@ -168,8 +168,7 @@ class ShopCore extends ObjectModel
|
||||
FROM '._DB_PREFIX_.'group_shop gs
|
||||
LEFT JOIN '._DB_PREFIX_.'shop s
|
||||
ON (s.id_group_shop = gs.id_group_shop)
|
||||
WHERE s.active = 1
|
||||
AND s.deleted = 0
|
||||
WHERE s.deleted = 0
|
||||
AND gs.deleted = 0
|
||||
ORDER BY gs.name, s.name';
|
||||
if ($results = Db::getInstance()->ExecuteS($sql))
|
||||
@@ -227,6 +226,22 @@ class ShopCore extends ObjectModel
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a shop ID from shop name
|
||||
*
|
||||
* @param string $name
|
||||
* @return int
|
||||
*/
|
||||
public static function getIdByName($name)
|
||||
{
|
||||
Shop::loadShops();
|
||||
foreach (self::$shops as $groupData)
|
||||
foreach ($groupData['shops'] as $shopID => $shopData)
|
||||
if (Tools::strtolower($shopData['name']) == Tools::strtolower($name))
|
||||
return $shopID;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int Total of shops
|
||||
*/
|
||||
@@ -536,7 +551,8 @@ class ShopCore extends ObjectModel
|
||||
{
|
||||
$html .= '<option class="group" value="g-'.$gID.'" '.(($value == 'g-'.$gID) ? 'selected="selected"' : '').'>'.htmlspecialchars($groupData['name']).'</option>';
|
||||
foreach ($groupData['shops'] as $sID => $shopData)
|
||||
$html .= '<option value="s-'.$sID.'" class="shop" '.(($value == 's-'.$sID) ? 'selected="selected"' : '').'>» '.$shopData['name'].'</option>';
|
||||
if ($shopData['active'])
|
||||
$html .= '<option value="s-'.$sID.'" class="shop" '.(($value == 's-'.$sID) ? 'selected="selected"' : '').'>» '.$shopData['name'].'</option>';
|
||||
}
|
||||
$html .= '</select>';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user