Jump to content

catzarov

Members
  • Posts

    58
  • Joined

  • Last visited

Profile Information

  • Location
    Bulgaria
  • Activity
    Freelancer

Recent Profile Visitors

579 profile views

catzarov's Achievements

Explorer

Explorer (4/14)

  • First Post Rare
  • Collaborator Rare
  • Conversation Starter Rare
  • Dedicated Rare
  • Week One Done Rare

Recent Badges

8

Reputation

  1. Hello, I found the solution myself, I will not use API but directly with database connection. The lower code for version 1.7.8.7 works correctly, which makes me very happy. I tested it on several products that were purchased in their last available sizes and had 0 quantity in the menu Monitoring -> "List of products with combinations but without available quantities for sale". With the code below, it is much faster to remove the 0 quantity. <?php $servername = "localhost"; // $username = ""; // $password = ""; // $dbname = ""; // $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id_product FROM ps17_product WHERE active = 1"; $result = $conn->query($sql); $active_products = array(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $active_products[] = $row["id_product"]; } } $zero_quantity_attributes = array(); foreach ($active_products as $product_id) { $sql = "SELECT pa.id_product_attribute FROM ps17_product_attribute pa JOIN ps17_stock_available sa ON pa.id_product_attribute = sa.id_product_attribute WHERE pa.id_product = $product_id AND sa.quantity = 0 AND pa.id_product_attribute NOT IN ( SELECT pa2.id_product_attribute FROM ps17_product_attribute pa2 JOIN ps17_stock_available sa2 ON pa2.id_product_attribute = sa2.id_product_attribute WHERE pa2.id_product = $product_id AND sa2.quantity > 0 )"; $result = $conn->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $zero_quantity_attributes[$product_id][] = $row["id_product_attribute"]; } } } $attribute_ids = array(); foreach ($zero_quantity_attributes as $product_id => $attributes) { foreach ($attributes as $attribute_id) { $sql = "SELECT id_attribute FROM ps17_product_attribute_combination WHERE id_product_attribute = $attribute_id"; $result = $conn->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $attribute_ids[$product_id][$attribute_id][] = $row["id_attribute"]; } } } } $attribute_names = array(); foreach ($attribute_ids as $product_id => $attributes) { foreach ($attributes as $attribute_id => $attribute_list) { foreach ($attribute_list as $attribute) { $sql = "SELECT name FROM ps17_attribute_lang WHERE id_attribute = $attribute AND id_lang = 1"; $result = $conn->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $attribute_names[$product_id][$attribute_id][] = $row["name"]; } } } } } if (count($attribute_names) > 0) { foreach ($attribute_names as $product_id => $attributes) { echo "<p>Product ID: $product_id</p>"; echo "<ul>"; foreach ($attributes as $attribute_id => $attribute_list) { foreach ($attribute_list as $attribute_name) { echo "<li>$attribute_name <form method='POST'><input type='hidden' name='product_id' value='$product_id'><input type='hidden' name='attribute_id' value='$attribute_id'><input type='submit' name='delete_attribute' value='DELETE'></form></li>"; } } echo "</ul>"; } } else { echo "No products with zero quantity found."; } if (isset($_POST['delete_attribute'])) { $product_id = $_POST['product_id']; $attribute_id = $_POST['attribute_id']; $sql_delete = "DELETE FROM ps17_product_attribute WHERE id_product = $product_id AND id_product_attribute = $attribute_id"; if ($conn->query($sql_delete) === TRUE) { echo "The attribute has been successfully deleted."; } else { echo "An error occurred when deleting the attribute: " . $conn->error; } } $conn->close(); ?> Best regards to all
  2. Hello @Nickz Thank you very much for your time and your comment on my question. You probably have a lot of knowledge, but I can't reach a solution to my problem after your comment. Please, if you understand what I have asked, give me a solution, a sample code or a correction of my code so that I understand you. I don't want to waste each other's time in comments, if you can't help me, just delete your comment, I'll delete mine so someone who understands can be helpful. I say this with the best of sentiments and intentions. In my PHP code maybe something needs to be added somewhere, but the prestashop documentation literature doesn't give me enough clarity on how to reach a solution myself, so I decided to ask. Best regards @Nickz
  3. Hello very honourable comrades I've read many forum threads, many search engine results, but can't find a solution! From all the synthesized information, I understand that ajax collects information about the availability of products with combinations. Someone please guide me, how with php can I extract a list in (standalone external file) which php script show me only ID or Ref# of products and which currently have 0 quantity in any of their sale attributes ? I tried to achieve this process through API, but somewhere my knowledge falls short and I can't pull out the availability. <?php // API URL for products $url_products = 'https://example.com/api/products/?display=[id,reference,name,active]&output_format=JSON'; // API Key $api_key = 'fullaccess'; // Initialize cURL for products $ch_products = curl_init($url_products); // Set cURL options for products curl_setopt($ch_products, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch_products, CURLOPT_HTTPHEADER, array( 'Authorization: Basic ' . base64_encode($api_key . ':') )); // Execute cURL request for products $response_products = curl_exec($ch_products); // Check for cURL errors for products if(curl_errno($ch_products)) { echo 'Error:' . curl_error($ch_products); } else { // Decode JSON response for products $data_products = json_decode($response_products, true); // Check if there are any products returned if(isset($data_products['products'])) { // Loop through products foreach($data_products['products'] as $product) { // Check if product is active if($product['active']) { // Extract product names from nested array of objects $product_names = array_column($product['name'], 'value'); // Combine product names into a single string $product_name = implode(', ', $product_names); // Output product ID, Ref, and Name echo "ID: " . $product['id'] . ", Ref: " . $product['reference'] . ", Name: " . $product_name . "<br>"; // API URL for product combinations $url_combinations = 'https://example.com/api/combinations/?display=[reference,quantity]&filter[id_product]=' . $product['id'] . '&output_format=JSON'; // Initialize cURL for product combinations $ch_combinations = curl_init($url_combinations); // Set cURL options for product combinations curl_setopt($ch_combinations, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch_combinations, CURLOPT_HTTPHEADER, array( 'Authorization: Basic ' . base64_encode($api_key . ':') )); // Execute cURL request for product combinations $response_combinations = curl_exec($ch_combinations); // Check for cURL errors for product combinations if(curl_errno($ch_combinations)) { echo 'Error:' . curl_error($ch_combinations); } else { // Decode JSON response for product combinations $data_combinations = json_decode($response_combinations, true); // Check if there are any combinations returned if(isset($data_combinations)) { // Loop through combinations and output reference and quantity foreach($data_combinations as $combination) { // Check if 'reference' and 'quantity' keys exist in the combination if(isset($combination['reference']) && isset($combination['quantity'])) { // Output reference echo "Size Ref: " . $combination['reference'] . ", "; // Output quantity attributes and their quantities foreach($combination['quantity'] as $attribute => $quantity) { echo $attribute . ": " . $quantity . " броя, "; } } else { echo "No combinations found for this product."; } // Add a line break echo "<br>"; } } else { echo "No combinations found for this product."; } } // Close cURL session for product combinations curl_close($ch_combinations); // Add a line break for better readability echo "<br>"; } } } else { echo "No products found."; } } // Close cURL session for products curl_close($ch_products); ?> For me, it's irrelevant whether I get the list via the API protocol or with programming code that directly messes with mysql and outputs the information. I just want to see that on product ID100, there are 0 quantity per size M and 0 quantity per size XXXL Thank you for your time and attention. Best regards
  4. Hello @mostafamoaz,I would advise you to only use the button in the back office for cleaning. Best regards.
  5. Hello @GalaxyIntern, Try clearing the cache. Advanced Parameters -> Performance -> Clear cache. Best regards.
  6. Hello All, (I need an urgent solution to this problem!) Yesterday I made an update from 1.7.8.7 to 1.7.8.8. The process went normally and without any errors. I use "1 click upgrade" official module. This morning when I opened the back office I found it strange that there were no new orders. I opened the public site and logged in as a customer. I fell into a state of terror. All products disappear from the site! e-doltcini-screen-error-products-not-show.webm The first thing I thought of was to clear the cache, (without a successful solution), then I regenerated the .htaccess file (again without a solution). I subsequently found that products disappear if the active language on the site is "English" or "French". If the active language of the site is my native language "Bulgarian", the products are displayed. The default language on the site is English. Please for your advice or ready solution to this case. Best regards.
  7. Hello misieq122, I think I've got you now, what do you want to do, you want to show the form box for a voucher, not a message alert! I don't think it's right, but I'll share with you what I know. /themes/classic/templates/checkout/_partials/cart-voucher.tpl Get from this file from line "53" to line "74" the html code. <div id="promo-code" class="collapse{if $cart.discounts|count > 0} in{/if}"> <div class="promo-code"> {block name='cart_voucher_form'} <form action="{$urls.pages.cart}" data-link-action="add-voucher" method="post"> <input type="hidden" name="token" value="{$static_token}"> <input type="hidden" name="addDiscount" value="1"> <input class="promo-input" type="text" name="discount_name" placeholder="{l s='Promo code' d='Shop.Theme.Checkout'}"> <button type="submit" class="btn btn-primary"><span>{l s='Add' d='Shop.Theme.Actions'}</span></button> </form> {/block} {block name='cart_voucher_notifications'} <div class="alert alert-danger js-error" role="alert"> <i class="material-icons">&#xE001;</i><span class="ml-1 js-error-text"></span> </div> {/block} <a class="collapse-button promo-code-button cancel-promo" role="button" data-toggle="collapse" data-target="#promo-code" aria-expanded="true" aria-controls="promo-code"> {l s='Close' d='Shop.Theme.Checkout'} </a> </div> </div> Then paste that code into a file: /themes/classic/templates/checkout/_partials/steps/payment.tpl on line 6, immediately after the line: {hook h='displayPaymentTop'} I haven't tested it in practice to see if it will work, but in that order of thought and action, if it doesn't work, look to revert your edit to the original version. best regards and success
  8. Hello misieq122, Simply select the hook of the module to appear only with step 3 (above the module for delivery) or step 4 (sub-methods for payment) I hope I've been helpful
  9. Hello StrefaBiznesu, You have a similar problem to mine. If you know how, take a look at the SQL table: "ps17_product_attribute". Find in it by the id of the product its available combinations and see if in the column defult_on has the digit 1 or is null. I have a feeling that all of us who use version 1.7.6 and above suffer with this defect in this table _product_attribute. In my case, the "quantity" column has a value of 0 for 99% of the products, and they actually have stock to sell. I've tried stopping or turning on the cache, clearing it, deleting the quantities manually and creating again. No result after my actions. I think a lot of problems come from: Catalogue -> Monitoring ->List of products with combinations but without available quantities for sale In the tuple menu, products appear that "apparently" have 0 quantity for a given attribute, but when you open the product it appears that all attributes are available. This is the BUG that we have all unwillingly endured for over a year now. If you find a solution yourself, be sure to come back and post it here as well, there's no telling when the same defect will call to us. Best regards.
  10. Hello all, I need information on how to plant a button to display in the mobile version of the site, not just in the desktop theme ? Currently I use the default theme but with a copy of "child theme". The "INFO" button was created using a module generated by contentbox.org. Accordingly, this same module is enabled for mobile devices, yet the button is not displayed on their screens. What should I do to preview the button in the mobile version of Prestashop ? Best regards to all.
  11. Hello @Steve023, Try it this way and see if it is acceptable to you. Best regards.
  12. Hello @roque_06 Open file: /themes/THEMENAME/templates/layouts/layout-both-columns.tpl On about line 35-37 you will see the <body> tag open. immediately after him put {literal} and {/literal}. Between the two literal tags put the code from google analytics. For me it works fine this way on both version 1.6 and version 1.7. Best regards.
  13. @4you.software I just can't describe the joy that lit up my face when I saw your kindness ♥ I sincerely hope you will make such a module. Even if it takes you a week of time, it would be nothing in front of eternity to spend an hour of time every day rubbing manually. I'll be looking forward to your download link. Maybe many other people will be happy.
  14. Hello @juanrojas, Thank you very much for the quick reply and the suggested link, unfortunately it is not what I and maybe thousands of other prestashop users are looking for. In Prestashop 1.7 there is a bug in the option "List of products with combinations but no available quantities for sale". This list also lists products with 0 quantity per attribute and products that have attributes available for sale. Before the bug appeared, it was easy because only products with 0 quantity per attribute were really listed. Now that the sheet is mixed a lot of time is wasted checking each product individually. With that said, I am looking to see if there is a solution to mass delete only the attributes that really have no quantity to sell. Maybe if you have the necessary knowledge and can make such a module, it will be very useful until the prestashop clear this bug with the attributes. ref links1: https://github.com/PrestaShop/PrestaShop/issues/12876 ref links2: https://github.com/PrestaShop/PrestaShop/issues/12814 An idea came to me as I was writing this comment now. If someone knows how to write PHP and understands what SQL query to submit to DB, maybe they can make a separate file by opening it in the browser to send a query to the database and delete the attributes of all products that have 0 quantity ?
  15. Hello comrades, In my store it pleases the massive defect that the product has 0 quantity for sale, but when I open it it appears that all attributes have stock for sale. Now in the out of stock list I have mixed products, ones that really have 0 quantity for an attribute and others that have stock. IT'S ALREADY VERY DIFFICULT FOR ME TO KEEP TRACK OF OVER 400 PRODUCTS! Someone please share with the audience, is it possible to mass delete if an attribute has 0 quantity, delete it and all other attributes that really have 0 quantity ? It is very annoying that the filter by layers indexes even an attribute with 0 quantity and when the customer searches by this attribute, opens the product and inside the size (attribute) is missing to buy! I will follow the topic with interest, because it takes me daily an hour of time to delete 0 quantity. Best regards: Dani
×
×
  • Create New...