Jump to content

Wilco i-Aspect

New Members
  • Posts

    2
  • Joined

  • Last visited

Wilco i-Aspect's Achievements

Newbie

Newbie (1/14)

  • One Month Later Rare
  • Week One Done Rare
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. Thank you for your responses. Below, I've included the relevant code from our PIM application that generates the XML file with the product data and sends it via a web service to our PrestaShop 8.1.6 setup. I use the web service provided by PrestaShop and have enabled all fields for ease since we are still in the concept phase. Function to Create the XML File with Product Data function createProductsXML($productData, array $shopCategories): bool|string { $xml = new SimpleXMLElement('<prestashop xmlns:xlink="http://www.w3.org/1999/xlink"></prestashop>'); $product = $xml->addChild('product'); $product->addChild('id_manufacturer', '1'); $product->addChild('id_supplier', '1'); $product->addChild('id_brand', '10'); $product->addChild('id_category_default', array_search($productData->category, $shopCategories)); $product->addChild('new', '1'); $product->addChild('id_default_combination', '1'); $product->addChild('id_tax_rules_group', '1'); $product->addChild('type', '1'); $product->addChild('id_shop_default', '1'); $product->addChild('reference', htmlspecialchars($productData->sku)); $product->addChild('supplier_reference', htmlspecialchars($productData->mpn)); $product->addChild('ean13', htmlspecialchars($productData->ean)); $product->addChild('available_for_order', "1"); $product->addChild('state', '1'); $product->addChild('product_type', 'standard'); $product->addChild('price', number_format($productData->price, 2)); $product->addChild('active', $productData->active ? '1' : '0'); $metaDescription = $product->addChild('meta_description'); $metaDescription->addChild('language', 'Description')->addAttribute('id', '1'); $metaDescription->addChild('language', 'Description')->addAttribute('id', '2'); $metaKeywords = $product->addChild('meta_keywords'); $metaKeywords->addChild('language', '')->addAttribute('id', '1'); $metaKeywords->addChild('language', '')->addAttribute('id', '2'); $metaTitle = $product->addChild('meta_title'); $metaTitle->addChild('language', '')->addAttribute('id', '1'); $metaTitle->addChild('language', '')->addAttribute('id', '2'); $linkRewrite = $product->addChild('link_rewrite'); $linkRewrite->addChild('language', '')->addAttribute('id', '1'); $linkRewrite->addChild('language', '')->addAttribute('id', '2'); $name = $product->addChild('name'); $name->addChild('language', htmlspecialchars($productData->name))->addAttribute('id', '1'); $name->addChild('language', htmlspecialchars($productData->name))->addAttribute('id', '2'); $description = $product->addChild('description'); $description->addChild('language', htmlspecialchars($productData->description))->addAttribute('id', '1'); $description->addChild('language', htmlspecialchars($productData->description))->addAttribute('id', '2'); $descriptionShort = $product->addChild('description_short'); $descriptionShort->addChild('language', '')->addAttribute('id', '1'); $descriptionShort->addChild('language', '')->addAttribute('id', '2'); $associations = $product->addChild('associations'); $categories = $associations->addChild('categories'); $category = $categories->addChild('category'); $category->addChild('id', array_search($productData->category, $shopCategories)); return $xml->asXML(); } Function to Send the POST Request public function post(string $url, string $content = null, bool $json_response = false): bool|string { if ($json_response) { $url = $url.'?output_format=JSON'; } $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); if ($content !== null) { curl_setopt($ch, CURLOPT_POSTFIELDS, $content); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/xml', 'Content-Length: ' . strlen($content) ]); } $response = curl_exec($ch); if (curl_errno($ch)) { throw new Exception('Request Error:' . curl_error($ch)); } curl_close($ch); return $response; }
  2. Hello Prestashop Community, I hope you're all doing well. I'm encountering a persistent issue with product listings in our Prestashop 8.1.6 setup, and I'm hoping someone can lend some insight into a solution. Here's the problem: We have our proprietary PIM (Product Information Management) application that generates products for our website. Following the comprehensive guide on creating products within Prestashop ("Creating a product - complete guide"), I ensure that the products are configured correctly. Everything appears to be in order: the products have stock and are indeed available for sale. However, despite this, the 'out of stock' label persists on the product detail page. To resolve this, I've discovered two temporary fixes: Manually saving the product in the admin interface removes the "out of stock" label. Altering the column 'cache_default_attribute' from '1' to '0' in the database table 'ps_product_shop' effectively removes the label upon page refresh. I've attempted to automate this process by including the field <cache_default_attribute><![CDATA[0]]></cache_default_attribute> in the XML files used to create products. Additionally, I experimented with the Postman collection provided by Prestashop, but unfortunately, the issue remains unresolved. I'm reaching out to see if anyone has encountered a similar issue or has suggestions on how to address it more efficiently. Any insights or guidance would be greatly appreciated. Thank you in advance for your time and assistance!
×
×
  • Create New...