Jump to content

enovo

Members
  • Posts

    19
  • Joined

  • Last visited

Profile Information

  • Location
    Uruguay
  • Activity
    Developer

Recent Profile Visitors

2,071,295 profile views

enovo's Achievements

Newbie

Newbie (1/14)

8

Reputation

  1. $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $opt = array('resource' => 'products'); $opt['postXml'] = $xml -> asXML(); $xml = $webService -> add($opt); $ProductId = $xml->product->id;
  2. hello, I developed a payment module and I want send mails notification with different mail templates, but I have not been able to do in any way, any ideas, someone can help me? I want to use different templates for different emails shipments.
  3. No, en la opcion imagenes tenes para regenerar las miniaturas
  4. To set the amount of the product must be done separately 1) Get the field ​​id and attribute_id from prefix_stock_available table for the product and an id for each combination. 2) After get the attribute_id go and have to change their values I copy two functions for this task and called after creating the product After add product: getIdStockAvailableAndSet($xml->product->id); function set_product_quantity($ProductId, $StokId, $AttributeId){ global $webService; $xml = $webService -> get(array('url' => PS_SHOP_PATH . '/api/stock_availables?schema=blank')); $resources = $xml -> children() -> children(); $resources->id = $StokId; $resources->id_product = $ProductId; $resources->quantity = 10000000; $resources->id_shop = 1; $resources->out_of_stock=1; $resources->depends_on_stock = 0; $resources->id_product_attribute=$AttributeId; try { $opt = array('resource' => 'stock_availables'); $opt['putXml'] = $xml->asXML(); $opt['id'] = $StokId ; $xml = $webService->edit($opt); }catch (PrestaShopWebserviceException $ex) { echo "<b>Error al setear la cantidad ->Error : </b>".$ex->getMessage().'<br>'; } } function getIdStockAvailableAndSet($ProductId){ global $webService; $opt['resource'] = 'products'; $opt['id'] = $ProductId; $xml = $webService->get($opt); foreach ($xml->product->associations->stock_availables->stock_available as $item) { //echo "ID: ".$item->id."<br>"; //echo "Id Attribute: ".$item->id_product_attribute."<br>"; set_product_quantity($ProductId, $item->id, $item->id_product_attribute); } }
  5. Solotion to the first question! If you use only one category use the next declaration: $resources->associations->categories->category->id = $n_id_category; Use the next syntax to asociate more cateogries $resources->associations->categories->addChild('category')->addChild('id', 2); $resources->associations->categories->addChild('category')->addChild('id', 3); $resources->associations->categories->addChild('category')->addChild('id', N);
  6. Here an examplo the how to add an image to a product. First, add a product! function PS_new_product($ImageId, $n_id_category_default, $n_id_category, $n_price, $n_active,$n_avail4order,$n_show_price, $n_id_stock_availables ,$n_id_id_product_attribute, $n_l_id, $n_name, $n_desc, $n_desc_short, $n_link_rewrite, $n_meta_title, $n_meta_description, $n_meta_keywords,$n_available_now,$n_available_later, $refernce, $ImagePath) { global $webService; $xml = $webService -> get(array('url' => PS_SHOP_PATH . '/api/products?schema=blank')); $resources = $xml -> children() -> children(); unset($resources->id); unset($resources->position); unset($resources->id_shop_default); unset($resources->date_add); unset($resources->date_upd); unset($resources->associations->combinations); unset($resources->associations->product_options_values); unset($resources->associations->product_features); unset($resources->associations->stock_availables->stock_available->id_product_attribute); //unset($resources->associations->categories->category->id); //unset($resources-> id_category_default); //$resources->position_in_category = '0'; //unset($resources->position_in_category); //$resources -> position = '0'; //$resources -> id; $resources-> id_manufacturer = '0'; $resources-> id_supplier = '0'; $resources-> id_category_default = $n_id_category_default; $resources-> new = '0'; ; //condition, new is also a php keyword!! $resources-> cache_default_attribute; $resources-> id_default_image; $resources-> id_default_combination = '0'; $resources-> id_tax_rules_group ='0'; //$resources-> id_shop_default; $resources-> reference = $refernce; $resources-> supplier_reference; $resources-> location; $resources-> width ; $resources-> height; $resources-> depth; $resources-> weight; $resources-> quantity_discount; $resources-> ean13; $resources-> upc; $resources-> cache_is_pack; $resources-> cache_has_attachments; $resources-> is_virtual ; $resources-> is_virtual_image = 1 ; $resources-> on_sale; $resources-> online_only; $resources-> ecotax; $resources-> minimal_quantity = 1; $resources-> price = $n_price; $resources-> wholesale_price; $resources-> unity; $resources-> unit_price_ratio; $resources-> additional_shipping_cost; $resources-> customizable; $resources-> text_fields; $resources-> uploadable_files; $resources-> active = $n_active; $resources-> available_for_order = $n_avail4order; $resources-> available_date; $resources-> condition; $resources-> show_price = $n_show_price; $resources-> indexed = '1'; $resources-> visibility = 'both'; $resources-> advanced_stock_management='0'; $resources-> date_add; $resources-> date_upd; $resources->associations->categories->addChild('category')->addChild('id', $n_id_category); //$node = dom_import_simplexml($resources -> name -> language[0][0]); //$no = $node -> ownerDocument; //$node -> appendChild($no -> createCDATASection($n_name)); $resources -> name -> language[0][0] = $n_name; $resources -> name -> language[0][0]['id'] = $n_l_id; $resources -> name -> language[0][0]['xlink:href'] = PS_SHOP_PATH . '/api/languages/' . $n_l_id; //$node = dom_import_simplexml($resources -> description -> language[0][0]); //$no = $node -> ownerDocument; //$node -> appendChild($no -> createCDATASection($n_desc)); $resources -> description -> language[0][0] = ($n_desc); $resources -> description -> language[0][0]['id'] = $n_l_id; $resources -> description -> language[0][0]['xlink:href'] = PS_SHOP_PATH . '/api/languages/' . $n_l_id; //$node = dom_import_simplexml($resources -> description_short -> language[0][0]); //$no = $node -> ownerDocument; //$node -> appendChild($no -> createCDATASection($n_desc_short)); $resources -> description_short -> language[0][0] = ($n_desc_short); $resources -> description_short -> language[0][0]['id'] = $n_l_id; $resources -> description_short -> language[0][0]['xlink:href'] = PS_SHOP_PATH . '/api/languages/' . $n_l_id; //$node = dom_import_simplexml($resources -> link_rewrite -> language[0][0]); //$no = $node -> ownerDocument; //$node -> appendChild($no -> createCDATASection($n_link_rewrite)); $resources -> link_rewrite -> language[0][0] = $n_link_rewrite; $resources -> link_rewrite -> language[0][0]['id'] = $n_l_id; $resources -> link_rewrite -> language[0][0]['xlink:href'] = PS_SHOP_PATH . '/api/languages/' . $n_l_id; //$node = dom_import_simplexml($resources -> meta_title -> language[0][0]); //$no = $node -> ownerDocument; //$node -> appendChild($no -> createCDATASection($n_meta_title)); $resources -> meta_title -> language[0][0] = ($n_meta_title); $resources -> meta_title -> language[0][0]['id'] = $n_l_id; $resources -> meta_title -> language[0][0]['xlink:href'] = PS_SHOP_PATH . '/api/languages/' . $n_l_id; //$node = dom_import_simplexml($resources -> meta_description -> language[0][0]); //$no = $node -> ownerDocument; //$node -> appendChild($no -> createCDATASection($n_meta_description)); $resources -> meta_description -> language[0][0] = substr ( $n_meta_description , 0, 245 )."...";; $resources -> meta_description -> language[0][0]['id'] = $n_l_id; $resources -> meta_description -> language[0][0]['xlink:href'] = PS_SHOP_PATH . '/api/languages/' . $n_l_id; //$node = dom_import_simplexml($resources -> meta_keywords -> language[0][0]); //$no = $node -> ownerDocument; //$node -> appendChild($no -> createCDATASection($n_meta_keywords)); $resources -> meta_keywords -> language[0][0] = $n_meta_keywords; $resources -> meta_keywords -> language[0][0]['id'] = $n_l_id; $resources -> meta_keywords -> language[0][0]['xlink:href'] = PS_SHOP_PATH . '/api/languages/' . $n_l_id; //$node = dom_import_simplexml($resources -> available_now -> language[0][0]); //$no = $node -> ownerDocument; //$node -> appendChild($no -> createCDATASection($n_available_now)); $resources -> available_now -> language[0][0] = $n_available_now; $resources -> available_now -> language[0][0]['id'] = $n_l_id; $resources -> available_now -> language[0][0]['xlink:href'] = PS_SHOP_PATH . '/api/languages/' . $n_l_id; //$node = dom_import_simplexml($resources -> available_later -> language[0][0]); //$no = $node -> ownerDocument; //$node -> appendChild($no -> createCDATASection($n_available_later)); $resources -> available_later -> language[0][0] = $n_available_later; $resources -> available_later -> language[0][0]['id'] = $n_l_id; $resources -> available_later -> language[0][0]['xlink:href'] = PS_SHOP_PATH . '/api/languages/' . $n_l_id; try { $opt = array('resource' => 'products'); $opt['postXml'] = $xml -> asXML(); // $opt['postXml'] = str_replace("&", "&", $opt['postXml']); //add the product at the site $xml = $webService -> add($opt); echo "New product inerted number: ". $xml->product->id."<br>"; //Id of the new product in prestashop site //## Add image add_image_to_product($xml->product->id, $refernce, $ImagePath); }catch (PrestaShopWebserviceException $ex) { echo "<b>$refernce ->Error : </b>".$ex->getMessage().'<br>'; //Show errors } } Now how to add image to a product! function add_image_to_product($ProductId, $ImageName, $ImagePath, $Width=640, $Height=640, $ImageQuality=100){ global $ImageTmpPath; //Make url $url = "http://mysite/api/images/products/$ProductId"; $resizeObj = new resize($ImagePath); //Resize iamge $resizeObj -> resizeImage($Width, $Height); //Save resized temp image $resizeObj -> saveImage("$ImageTmpPath/$ImageName", $ImageQuality); //Uplodad image to a product $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_PUT, true); // Un-commet to edit an image curl_setopt($ch, CURLOPT_USERPWD, PS_WS_AUTH_KEY.':'); curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => '@'."$ImageTmpPath/$ImageName")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); //Delete temp image unlink("$ImageTmpPath/$ImageName"); }
  7. Entiendo, pero lo que digo que en la doc debería estar, en ninguna lado excepto aquí habla sobre esto
  8. Bueno, tal vez si sea ese el problema, estaría bueno que este en la documentación oficial de prestashop, borre dicho archivo y vi que prestashop lo volvio a generar pero ahora con la definicion de la ruta de el archivo que creeo yo para sobreescribir la clase productos Antes: 'Product' => '', Despues: 'Product' => 'override/classes/Product.php', Fijarse en la linea 500 por ahi del archivo cache/class_index.php, en el caso de product.php
  9. Yo estoy tratando de hacer override de la Clase product.php pero no me funciona, o sea levanta la origina y no la mia que está ubicada en override\classes\Product.php, la única forma que vi de que funcionara es haciendo lo que dijo joseantgv, de agarrar y borrar el archivo cache/class_index.php, aunque no me parece lo correcto, en la documentación no esta este procedimiento!
  10. <div>Hi, I need to extend functionality of prestashop products and features thereof, my idea is to develop a module that is self-installable, my question is, in the implementation of my module I can overwrite behavior prestashop products or I need to do besides adding a new file in the override folder for this purpose and from there extend its functionality?</div> <div> </div> <div>I did not find documentation that specifies this, I want to be a downloadable module with my new functionality.</div>
  11. Estimados, les hago una pregunta tal vez alguno de ustedes me pueda ayudar, voy a crear productos virtuales pero en mi caso serán fotografias, lo que quiero es que por ejemplo cada producto que es una fotografía aparezca con varios tamaños y que el cliente pueda comprar el tamaño que quiera, obviamente que la mas chica es la mas barata y la full la mas cara, quiero implementar esto pero no se como hacerlo, agradezco si alguien me puede ayudar. Bueno pego de-nuevo la solución al problema que todos reclaman que no se envia el mail para descargar el producto. Version: PrestaShop™ 1.5.4.1 Sigue teniendo un Bug que no manda el e-mail con el link de la descarga del producto y se corrige según el siguiente link. http://forge.prestashop.com/browse/PNM-1355?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel Concretamente hay que hacer lo siguiente en dicha version: Archivo: classes/order/OrderHistory.php Línea: 103 Modificar esto: if (Validate::isLoadedObject($order) && ($old_os instanceof OrderState) && ($new_os instanceof OrderState)) Por esto: if (Validate::isLoadedObject($order) && ($new_os instanceof OrderState))
  12. Aquí la solucion para la ultima version: http://forge.prestashop.com/browse/PNM-1355?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel
×
×
  • Create New...