Jump to content

drasl

Members
  • Posts

    55
  • Joined

  • Last visited

Profile Information

  • Location
    España
  • Activity
    Freelancer

Recent Profile Visitors

427 profile views

drasl's Achievements

Newbie

Newbie (1/14)

6

Reputation

1

Community Answers

  1. Done. The solution: foreach ($product_array['tags_array'] as $lang => $lang_tags){ Tag::addTags($lang, $product->id, $lang_tags); } Now I update my code if someone need it: public function createProduct($product_array){ /******** Example argument $product_array ********/ /* $product_array['ean13'] = 9999999; $product_array['name'] = [3 => 'Prueba producto',4 => 'Prueba producto portugal']; $product_array['link_rewrite'] = [3 => 'prueba_producto', 4 => 'prueba_producto_portugal']; $product_array['id_category'] = [2,3]; $product_array['id_category_default'] = 2; $product_array['redirect_type'] = '404'; $product_array['wholesale_price'] = 0; $product_array['price'] = 0; $product_array['id_tax_rules_group'] = 9; $product_array['quantity'] = 2; $product_array['minimal_quantity'] = 1; $product_array['show_price'] = 1; $product_array['active'] = 0; $product_array['online_only'] = 1; $product_array['meta_keywords'] = 'test'; $product_array['meta_description'] = 'test'; $product_array['is_virtual'] = 0; $product_array['weight'] = 2; $product_array['reference'] = 'ASD'; $product_array['id_manufacturer'] = 1; $product_array['images'][] = array(true,'url'); // $cover, $url $product_array['images'][] = array(false,'url'); // $cover, $url // Variables de combinación $product_array['combinations'][1]['id_image'] = 1; //Imágen del producto correspondiente a esta combinación $product_array['combinations'][1]['wholesale_price'] = 0; $product_array['combinations'][1]['price'] = 5; $product_array['combinations'][1]['weight'] = 3; $product_array['combinations'][1]['quantity'] = 2; $product_array['combinations'][1]['reference'] = 'referencia_combinacion'; $product_array['combinations'][1]['ean13'] = '1234567890123'; $product_array['combinations'][1]['default_on'] = true; $product_array['combinations'][1]['upc'] = ""; $product_array['combinations'][1]['minimal_quantity'] = 1; // Atributos de combinación $product_array['combinations'][1]['combination_attributes'][] = 25; $product_array['combinations'][1]['combination_attributes'][] = 26; */ //Creating the product Shop::setContext(Shop::CONTEXT_ALL); $error = ""; $product = new Product(); $product->ean13 = $product_array['ean13']; $product->name = $product_array['name']; $product->link_rewrite = $product_array['link_rewrite']; $product->id_category = $product_array['id_category']; $product->id_category_default = $product_array['id_category_default']; $product->redirect_type = $product_array['redirect_type']; $product->wholesale_price = $product_array['wholesale_price']; $product->price = $product_array['price']; $product->id_tax_rules_group = $product_array['id_tax_rules_group']; $product->quantity = $product_array['quantity']; $product->minimal_quantity = $product_array['minimal_quantity']; $product->show_price = $product_array['show_price']; $product->active = $product_array['active']; $product->online_only = $product_array['online_only']; $product->meta_keywords = $product_array['meta_keywords']; $product->meta_description = $product_array['meta_description']; $product->is_virtual = $product_array['is_virtual']; $product->weight = $product_array['weight']; $product->referende = $product_array['reference']; $product->id_manufacturer = $product_array['id_manufacturer']; if ($product->add()){ $product->updateCategories($product->id_category); StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, Context::getContext()->shop->id); //Añado los tags foreach ($product_array['tags_array'] as $lang => $lang_tags){ Tag::addTags($lang, $product->id, $lang_tags); } //Crea imágenes foreach ($product_array['images'] as $product_image){ $cover = $product_image[0]; $url = $product_image[1]; $id_product = $product->id; $image = new Image(); $image->id_product = $id_product; $image->position = Image::getHighestPosition($id_product) + 1; $image->cover = $cover; if (($image->validateFields(false, true)) === true && ($image->validateFieldsLang(false, true)) === true && $image->add()){ $image->associateTo(Context::getContext()->shop->id); if (!$this->copyImg($id_product, $image->id, $url, 'products')){ $image->delete(); $error .= "<li>Ha ocurrido un fallo con la imágen</li>"; } } } //Creo combinaciones $id_shop_list = array(1,2); $id_product_attribute = $product->addCombinationEntity( (float)$product_array['combinations'][1]['wholesale_price'], (float)$product_array['combinations'][1]['price'], (float)$product_array['combinations'][1]['weight'], 0, 0, (int)$product_array['combinations'][1]['quantity'], $product_array['combinations'][1]['id_image'], strval($product_array['combinations'][1]['reference']), 0, strval($product_array['combinations'][1]['ean13']), (int)$product_array['combinations'][1]['default_on'], 0, strval($product_array['combinations'][1]['upc']), (int)$product_array['combinations'][1]['minimal_quantity'], $id_shop_list ); // Si la combinación se ha creado correctamente... if ($product->productAttributeExists($id_product_attribute)){ //Creo atributos if (!$product->addAttributeCombinaison($id_product_attribute, $product_array['combinations'][1]['combination_attributes'])){ $error = "<li>Ocurrió un problem al crear el/los atributo/s para la combinacón"; }else{ StockAvailable::setQuantity((int)$product->id, $id_product_attribute, (int)$product_array['combinations'][1]['quantity'], Context::getContext()->shop->id); } }else{ $error .= "<li>Ocurrió un error al crear la combinación!"; } echo "Producto con ID: ".$id_product." creado correctamente!"; }else{ $error .= "<li>Ha ocurrido un error al crear el producto"; } // Si no hay errores, creo producto en tienda remota. if ($error != ""){ return true; }else{ return $error; } }
  2. Hi all! I'm actually working on my own function to create product, because I have multiple shops in prestashop with different names, diferent hosts and same products. That's why I need to design a product form to create/modify/delete products. I'm now stucked in the point that I don't know how to create the product TAGS, I tested like this: $product->tags = array('test1','test2'); $product->tags = 'test1,test2'); But the tags won't be created. I will paste my code here and I will update it: public function createProduct($product_array){ //Array con todas las variables de producto $error = ""; Shop::setContext(Shop::CONTEXT_ALL); $product = new Product(); $product->ean13 = $product_array['ean13']; $product->name = $product_array['name']; $product->link_rewrite = $product_array['link_rewrite']; $product->id_category = $product_array['id_category']; $product->id_category_default = $product_array['id_category_default']; $product->redirect_type = $product_array['redirect_type']; $product->price = $product_array['price']; $product->id_tax_rules_group = $product_array['id_tax_rules_group']; $product->quantity = $product_array['quantity']; $product->minimal_quantity = $product_array['minimal_quantity']; $product->show_price = $product_array['show_price']; $product->active = $product_array['active']; $product->online_only = $product_array['online_only']; $product->meta_keywords = $product_array['meta_keywords']; $product->meta_description = $product_array['meta_description']; $product->is_virtual = $product_array['is_virtual']; $product->weight = $product_array['weight']; $product->referende = $product_array['reference']; $product->id_manufacturer = $product_array['id_manufacturer']; if ($product->add()){ $product->updateCategories($product->id_category); StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, Context::getContext()->shop->id); //Crea imágenes foreach ($product_array['images'] as $product_image){ $cover = $product_image[0]; $url = $product_image[1]; $id_product = $product->id; $image = new Image(); $image->id_product = $id_product; $image->position = Image::getHighestPosition($id_product) + 1; $image->cover = $cover; if (($image->validateFields(false, true)) === true && ($image->validateFieldsLang(false, true)) === true && $image->add()){ $image->associateTo(Context::getContext()->shop->id); if (!$this->copyImg($id_product, $image->id, $url, 'products')){ $image->delete(); $error .= "<li>Ha ocurrido un fallo con la imágen</li>"; } } } echo "Producto con ID: ".$id_product." creado correctamente!"; }else{ $error .= "<li>Ha ocurrido un error al crear el producto"; } } Thanks in advance!
  3. Ye I know, we will update to 1.7 soon. Thanks anyways.
  4. Solved, Commented the function addonsRequest in "classes/Tools.php". The parameter " ?action=must-have-themes " is deprecated.
  5. I don't know what module calls to "http://api.addons.prestashop.com" but it is returning an error. I blocked all the traffic to the 91.240.109.18 by firewall and now my backoffice is working, but before I did it, that calls to api addons was slowing down all my backoffice. The message that api.addons.prestashop.com is returning is: " {"errors":{"code":"0015","label":"Fatal error : method is undefined."[spam-filter] " Don't know where can I post this error so they can solve it asap. Regards.
  6. Ok I found it! The hook is called: DisplayAdminCustomers Solved!
  7. Hi, Like the title says I want to add a panel in the Back Office -> Customers. I don't know is there are any hooks to do this or I have to modify the tpl to do that... Someone knows? Look at the attached image please. Thanks!
  8. Para eso tienes que acceder a la base de datos desde el controlador de Prestashop y asignarle ese valor a una variable smarty, y así poder usarla en el archivo "category.tpl"
  9. Qué fila de la base de datos querrías coger?
  10. En el backoffice modifica la categoría en cuestión y usa la descripción de la misma para poner lo que tu quieras. Después oculta mediante CSS la clase "cat-name" (Esto dejará de mostrar la palabra el nombre de la categoría) .cat-name{ display:none; } Como segunda opción, puedes eliminar la etiqueta h1 del archivo .tpl de tu plantilla, el archivo se llama category.tpl
  11. Thanks musicmaster. Of course I know computers tends to be logical, if you think that the things I write sounds like I consider computer are irrational you're wrong and you really misunderstood me, maybe because I'm Spanish and I can't communicate in the best way. There is no problem about antispam, the clients who confirms the mail ALWAYS will be updated to "is_confirmed = 1". The problem is not the mail with the hash are marked as spam. The hash is properly escaped in the query. Damaged codes in the process of encoding and decoding, maybe, i'm now tracking the code with logs. I will tell you. Thanks for your participation.
  12. Because there are customers with the mail confirmed but they haven't de coupon active. These clients who has this issue are normal clients.
  13. Tendrías que tocar el controlador, obtener la IP del cliente que está accediendo a la página web, geolocalizar la IP para obtener el país y después no mostrar esa categoría... si tienes conocimientos avanzados sobre Prestashop podrías hacerlo fácil.... si no dominas mucho Prestashop, se me ocurre que podrías hacerlo a través de Javascript, y ocultas vía CSS la categoría en relación a la IP del cliente.
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More