public static function getInheritedIsMultiSku($id_category_ref, $ebay_site_id) { $row = Db::getInstance()->getRow('SELECT `id_category_ref_parent`, `is_multi_sku` FROM `' . _DB_PREFIX_ . 'ebay_category` WHERE `id_category_ref` = ' . (int) $id_category_ref . ' AND `id_country` = ' . (int) $ebay_site_id); if ($row['is_multi_sku'] !== null) { return $row['is_multi_sku']; } if ((int) $row['id_category_ref_parent'] != (int) $id_category_ref) { return EbayCategory::getInheritedIsMultiSku($row['id_category_ref_parent'], $ebay_site_id); } return $row['is_multi_sku']; }
private function _getAlertCategories() { $alert = ''; $cat_with_problem = array(); $sql_get_cat_non_multi_sku = 'SELECT * FROM ' . _DB_PREFIX_ . 'ebay_category_configuration AS ecc INNER JOIN ' . _DB_PREFIX_ . 'ebay_category AS ec ON ecc.id_ebay_category = ec.id_ebay_category'; foreach (Db::getInstance()->ExecuteS($sql_get_cat_non_multi_sku) as $cat) { if ($cat['is_multi_sku'] != 1 && EbayCategory::getInheritedIsMultiSku($cat['id_category_ref']) != 1) { $catProblem = 0; $category = new Category($cat['id_category']); $products = $category->getProductsWs($this->ebay_country->getIdLang(), 0, 300); foreach ($products as $product_ar) { $product = new Product($product_ar['id']); $combinations = version_compare(_PS_VERSION_, '1.5', '>') ? $product->getAttributeCombinations($this->context->cookie->id_lang) : $product->getAttributeCombinaisons($this->context->cookie->id_lang); if (count($combinations) > 0 && !$catProblem) { $cat_with_problem[] = $cat['name']; $catProblem = 1; } } } } $var = implode(', ', $cat_with_problem); if (count($cat_with_problem) > 0) { if (count($cat_with_problem == 1)) { // RAPH: pb here in the test. Potential typo $alert = '<b>' . $this->l('You have chosen eBay category : ') . $var . $this->l(' which does not support multivariation products. Each variation of a product will generate a new product in eBay') . '</b>'; } else { $alert = '<b>' . $this->l('You have chosen eBay categories : ') . $var . $this->l(' which do not support multivariation products. Each variation of a product will generate a new product in eBay') . '</b>'; } } return $alert; }
public static function getMultiVarToNonMultiSku($ebay_profile, $context) { $cat_with_problem = array(); $sql_get_cat_non_multi_sku = 'SELECT * FROM ' . _DB_PREFIX_ . 'ebay_category_configuration AS ecc INNER JOIN ' . _DB_PREFIX_ . 'ebay_category AS ec ON ecc.id_ebay_category = ec.id_ebay_category WHERE ecc.id_ebay_profile = ' . (int) $ebay_profile->id . ' GROUP BY name'; foreach (Db::getInstance()->ExecuteS($sql_get_cat_non_multi_sku) as $cat) { if ($cat['is_multi_sku'] != 1 && EbayCategory::getInheritedIsMultiSku($cat['id_category_ref'], $ebay_profile->ebay_site_id) != 1) { $catProblem = 0; $category = new Category($cat['id_category']); $ebay_country = EbayCountrySpec::getInstanceByKey($ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT')); $products = $category->getProductsWs($ebay_country->getIdLang(), 0, 300); foreach ($products as $product_ar) { $product = new Product($product_ar['id']); $combinations = version_compare(_PS_VERSION_, '1.5', '>') ? $product->getAttributeCombinations($context->cookie->id_lang) : $product->getAttributeCombinaisons($context->cookie->id_lang); if (count($combinations) > 0 && !$catProblem) { $cat_with_problem[] = $cat['name']; $catProblem = 1; } } } } return $cat_with_problem; }
public static function getInheritedIsMultiSku($id_category_ref) { $row = Db::getInstance()->getRow('SELECT `id_category_ref_parent`, `is_multi_sku` FROM `' . _DB_PREFIX_ . 'ebay_category` WHERE `id_category_ref` = ' . (int) $id_category_ref); if ($row['is_multi_sku'] !== null) { return $row['is_multi_sku']; } if ((int) $row['id_category_ref_parent'] != (int) $id_category_ref) { return EbayCategory::getInheritedIsMultiSku($row['id_category_ref_parent']); } return $row['is_multi_sku']; // RArbuz: shall we not return the category default in this case? }