private function getAlertCategories() { $alert = ''; $sql_getCatNonMultiSku = "SELECT * FROM " . _DB_PREFIX_ . "ebay_category_configuration AS ecc\r\n\t\t\tINNER JOIN " . _DB_PREFIX_ . "ebay_category AS ec ON ecc.id_ebay_category = ec.id_ebay_category"; $CatNonMultiSku = Db::getInstance()->ExecuteS($sql_getCatNonMultiSku); $catWithProblem = array(); foreach ($CatNonMultiSku as $cat) { if ($cat['is_multi_sku'] != 1 && $this->findIfCategoryParentIsMultiSku($cat['id_category_ref']) != 1) { $categorie = new Category($cat['id_category']); $products = $categorie->getProductsWs($this->id_lang, 0, 300); $catProblem = 0; foreach ($products as $productArray) { $product = new Product($productArray['id']); $combinations = $product->getAttributeCombinaisons($this->id_lang); if (count($combinations) > 0 && $catProblem == 0) { $catWithProblem[] = $cat['name']; $catProblem = 1; } } } } $var = ''; $j = 0; foreach ($catWithProblem as $cat) { if ($j != 0) { $var .= ', '; } $var .= $cat; $j++; } if (count($catWithProblem) > 0) { if (count($catWithProblem == 1)) { $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; }
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; }
/** * Controls and changes, if possible, category's active parameter if a product's active parameter changes. * * @param array $ids_categories_array * @return * */ private function controlCategoriesForActivateTheir($ids_categories_array) { $size_array_categories = sizeof($ids_categories_array); for ($i = 0; $i < $size_array_categories; $i++) { $tmp = $ids_categories_array[$i]; $category = new Category((int) $tmp["id"]); $array_of_ids_products = $category->getProductsWs(); $size_array_products = sizeof($array_of_ids_products); $count = 0; for ($j = 0; $j < $size_array_products; $j++) { $array_prod = $array_of_ids_products[$j]; $product = new Product((int) $array_prod["id"]); if (!$product->active) { $count++; } } if ($count == $size_array_products) { $category->active = 0; $category->update(); } else { $category->active = 1; $category->update(); } } }