/** * @return bool */ public function delete() { $iIdFeature = $this->id_feature; $return = parent::delete(); /* Reinitializing position */ $this->cleanPositions($iIdFeature); return $return; }
public function delete() { /* Also delete related products */ Db::getInstance()->execute(' DELETE FROM `' . _DB_PREFIX_ . 'feature_product` WHERE `id_feature_value` = ' . (int) $this->id); $return = parent::delete(); if ($return) { Hook::exec('actionFeatureValueDelete', array('id_feature_value' => $this->id)); } /* Reinitializing position */ $this->cleanPositions($this->id_feature); return $return; }
/** * Get all language for a given value * * @param bool $id_feature_value Feature value id * @return array Array with value's languages */ public static function getFeatureValueLang($id_feature_value) { return \FeatureValueCore::getFeatureValueLang($id_feature_value); }
/** * Updates a product on Prestashop. * * @param array $product_attributes * @param integer $id_product * @param string $url_photo * @param array $triple_cod_col_siz * @param integer $language * @param array $array_combinations * @return array * @see $this->isOldNameProductEgualToNewNameProduct * @see $this->isOldOrNewValueForProduct * @see $this->controlCategoriesForActivateTheir * @see $this->updateCombinantionsForPrestashop * */ public function updateProductForPrestashop($product_attributes = array(), $id_product, $url_photo, $triple_cod_col_siz, $array_combinations, $language = 1) { $product = new Product($id_product); $is_change_product = false; $new_name_product = trim($product_attributes["Nome"]); if (!$this->isOldNameProductEgualToNewNameProduct($product->name, $new_name_product)) { $product->name = $this->setArrayElementForLinkRewrite($new_name_product, true, $language); $product->meta_keywords = $new_name_product; $product->link_rewrite = $this->setArrayElementForLinkRewrite($new_name_product, false, $language); $is_change_product = true; } $new_price = (double) $product_attributes["Prezzo"]; if (!$this->isOldOrNewValueForProduct((double) $product->price, $new_price)) { $product->price = $new_price; $is_change_product = true; } $new_active = (int) $product_attributes["Attivo"]; $control_category = $this->isOldOrNewValueForProduct((int) $product->active, $new_active); if (!$control_category) { $product->active = $new_active; $is_change_product = true; } $new_minimal_quantity = (int) $product_attributes["Qta_min"]; if (!$this->isOldOrNewValueForProduct((int) $product->minimal_quantity, $new_minimal_quantity)) { $product->minimal_quantity = $new_minimal_quantity; $is_change_product = true; } $new_quantity = (int) $product_attributes["Qta"]; if (!$this->isOldOrNewValueForProduct((int) $product->getQuantity($id_product), $new_quantity)) { StockAvailable::setQuantity($id_product, 0, $new_quantity); } $array_old_features = $product->getFeatures(); $array_features = $product_attributes["Feature"]; $height = false; $width = false; foreach ($array_old_features as $array_old_single_features) { $feature = new FeatureCore((int) $array_old_single_features['id_feature']); $tmp_feature = $feature->name; $single_old_feature = $tmp_feature[$language]; $feature_value = new FeatureValueCore((int) $array_old_single_features["id_feature_value"]); $tmp_feature_value = $feature_value->value; $single_old_feature_value = $tmp_feature_value[$language]; if ($this->isOldOrNewValueForProduct("Altezza", $single_old_feature)) { if (!$this->isOldOrNewValueForProduct($single_old_feature_value, $array_features["Altezza"] . " cm")) { $feature_value->value = array($language => $array_features["Altezza"] . " cm"); $feature_value->update(); $height = true; $is_change_product = true; } } if ($this->isOldOrNewValueForProduct("Larghezza", $single_old_feature)) { if (!$this->isOldOrNewValueForProduct($single_old_feature_value, $array_features["Larghezza"] . " cm")) { $feature_value->value = array($language => $array_features["Larghezza"] . " cm"); $feature_value->update(); $width = true; $is_change_product = true; } } if ($this->isOldOrNewValueForProduct("Lunghezza", $single_old_feature)) { if (!$this->isOldOrNewValueForProduct($single_old_feature_value, $array_features["Lunghezza"] . " cm")) { $feature_value->value = array($language => $array_features["Lunghezza"] . " cm"); $feature_value->update(); $is_change_product = true; } } if ($this->isOldOrNewValueForProduct("Modello", $single_old_feature)) { if (!$this->isOldOrNewValueForProduct($single_old_feature_value, $array_features["Modello"])) { $feature_value->value = array($language => $array_features["Modello"]); $feature_value->update(); $is_change_product = true; } } if ($this->isOldOrNewValueForProduct("Linea", $single_old_feature)) { if (!$this->isOldOrNewValueForProduct($single_old_feature_value, $array_features["Linea"])) { $feature_value->value = array($language => $array_features["Linea"]); $feature_value->update(); $is_change_product = true; } } } if ($height) { $product->height = (double) $array_features["Altezza"]; $is_change_product = true; } if ($width) { $product->width = (double) $array_features["Larghezza"]; $is_change_product = true; } if ($is_change_product) { $product->update(); } if (!$control_category) { $ids_categories_array = $product->getWsCategories(); $this->controlCategoriesForActivateTheir($ids_categories_array); } $change_new_image = $this->updateCombinantionsForPrestashop($id_product, $url_photo, $triple_cod_col_siz, $array_combinations, $language); $string_triple = array(); $return = array(); array_push($return, $product->id); $array_images_combinations_of_the_product = $product->getImages($language); $element = array(); foreach ($array_images_combinations_of_the_product as $array_combo_image) { $name_of_the_image = $array_combo_image['legend']; $id_image_of_the_product = $array_combo_image['id_image']; array_push($element, $id_image_of_the_product . ";" . $name_of_the_image); } array_push($return, $element); foreach ($change_new_image as $array_combo_image) { $fetch_tmp = explode(";", $array_combo_image); $fetch_jpg = explode(".jpg", $fetch_tmp[1]); $fetch_image_name = explode(",", $fetch_jpg[0]); array_push($string_triple, $fetch_image_name[2]); } array_push($return, $change_new_image); array_push($return, $string_triple); return $return; }