How to remove out of stock woocommerce products? - php

As the title describes i want to delete all the out of stock products from my woocommerce eshop at the end of the day. Every day morning i import 6000 products with their images from another server and 600-700 are out of stock. So every day i upload 700 trash in my server and i have to delete manually at the end of the day cause server data limitations. I found these related questions
How to move out of stock product to trash Woocommerce?
Woocommerce delete products which are "Out of stock"
but the problem is that if i run one of these sql codes in functions.php file the products can be deleted but the thumbnails and images of the products are remain in my server and i have to delete manually.

I would prevent the out or stock products from being imported in the first place?
How are you importing these products in the first place? The import takes place, usually via a CSV which can contain as little or as much information as you require. One column is called 'In stock?' with either a value of 1 for in stock, or 0 for out of stock.
So in your import file you can just remove the products that have a value of 0 for 'In stock?' and then carry on as normal. That way no images etc will be imported.

Related

Cannot Export Import Products on Backend Magento

I've tried to export products + category from X magento to Y magento with this https://www.siteground.com/tutorials/magento/import-products.htm
FYI, the exported files are correct, even XML or CSV type.
But, i found error when i importing it. it says i found 84 rows, but it's only Imported 1 records, when i check the Manage Products, none of products is imported. I tried on CSV and XML files, the result are same.
The magento version of both are similar, any possibilities to debug it?
In your import process 84 records means there is 84 lines in your csv file not 84 products!
I guess you're using just one sku for all of your products and that's why you have just one imported product. It's good to know that
magento uses sku as ID to identify products, so you need to assign an unique sku to every single product.
Update:
To insert new products by CSV Import check this columns in your csv file.
Required Product Attributes for New Products (written as they should appear in the CSV file column):
sku
Stock Keeping Unit - a unique value to identify the product. No two items can share the same SKU in Pixafy.
_attribute_set
Unless you have already set up Attribute Sets, set this to "Default"
_type
What type of product is this? Your options are: simple, configurable, virtual, and downloadable. Grouped or bundle products can not be imported at this time and must be created in the Control Panel.
name
The product's name- such as "Magic Wand". This should not be longer than 60 characters
description
The long description with detailed information regarding the product.
short_description
The shorter description that appears to the right of the Product Image on the Product page
price
The amount you are charging your customers for this product before sales or discounts.
status
Is the product Enabled or Disabled? Enabled is 1, Disabled, 2
visibility
How will the customer be able to view this item?
Visible in Catalog and Search = 4
Visible in Catalog =2
Visible in Search = 3
Not visible individually = 1
tax_class_id
Tax Class ID as set up under Set Up > Tax > Product Tax Classes. By default, Taxable Goods are 2
weight
Enter a numerical value for the weight of this product. This will be used by any calculated shipping methods.
_product_websites
At this time, your only option is base
Update 2:
To learn how to add product images to your csv file, read this post:
Update Magento products with multiple images

Magento Products are not showing in Shop

Hope you can help me today. I imported about 85.000 Products from an SQL Source via Magmi. These Products are showing in the backend, they are "active", I updated the index (all of them), deleted the cache, made sure, that the products are in any category, made sure all mandatory fields are filled out, and they have a price. The products are not in Stock, but when I manually add a product thats not in stock, it is shown in the shop. And if i modify an imported product and increase the amount I have in stock, they are still not shown.
The products are all visible in catalog and in search, but I just cant find then clicking on the category in the menu. But if I search for a specific product I can find it.
Got anybody an idea?
Cheers
EDIT: Here I got a picture from Magmi import Process
And i only have one store, and one store view, that has default values
Following things you can check -
Check Visibility of the product.
Check if the product is assigned to a category.
Check if the product is assigned to a store view.
Check if the product is In Stock.
Check if the product has a qty assigned.

Hide blank or zero priced prducts after import

I have a WooCommerce with automatic products import from a source and I have 2 different files to import: first one is for products, second one for prices and stocks.
Sometimes I import products that are still not present in the second file, and I get a list of "blank" price products that goes online on my shop.
How can I tell WooCommerce to not show those products?

Restricting customers to max of 2 purchases for a certain product in Magento

I currently have an issue trying to restrict customers to purchasing 2 of a product max.
So far, I can set the max number of the product in the cart to 2 using catalog/manage products, select the product, then inventory and adjusting the max Qty allowed in cart to 2.
However, this will not stop the user coming back another day and purchasing another 2 items.
What I would like to do is create a rule so that when the user logs in and tries to purchase the product, after already purchasing it, the code will throw an error saying that they have reached their max quantity and prevent the cart from processing the order.
I believe that I would have to edit one of the php files to run a check against the users id and the product id, but I am unsure which file will need to be edited.
Magento ver. 1.3.2.4
Links that helped me, hope it helps:
step 1
step 2
First of all create one observer checkout_cart_add_product_before
In this observer event check cart quantity of product, you can get qoute item from quote object and from quote retrieve product quantity and match with newly added product if condition satisfied then redirect customer to product details page with mesage
To support future compatibility and prevent your changes from being overwritten you should create a custom extension that hooks into the core.
You might try the hook: checkout_cart_add_product_complete or checkout_cart_add_product_before and test the number of items of each product. Based on that result you might automatically remove the item and parse an error.

Magento product delete not working

I am using Magento 1.7.0.2 and have encountered a problem when deleting products. I create 20 products in a clean install of magento using the product import routine. The products where assigned to categories, and had images associated with them. The products displayed perfectly.
I then went in to the back end and deleted the products by selecting them from the product grid and choosing delete. This worked fine on the face of it and the products disappeared from the products grid.
I then attempted to re-import the products using the same format import file with some slightly different descriptions ect (SKU's were the same as previously) and I get an error saying that the SKU must be unique.
I have attempted creating a simple product in the back end with several of the now deleted SKU's and I get the same error - sku must be unique.
I have noticed that if I go into the category within the back end the deleted products are still listed against the category - I cant un-associate them as the products are not visible in the product list.
The products are not visible within the store,and I have tried the following:
refreshing the indexes and deleting the cash multiple times
Using the mage api to try deleting the phantom items - this just errors as stock item not found
Tried using the Mage and Soap API's to re-create the item, but get the same SKU must be unique error
Does any body have any ideas? I assume it should be possible to delete an item from the product list and re-create it?
If I cant fully delete the item is there a way for me to un-delete it? so I can then just update the profile?
I don't know why SKU still exists in your system after delete products. But you can solve your problem by execute SQL statement bellow:
DELETE * FROM catalog_product_entity WHERE sku='XXXX';

Categories