Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Remove WooCommerce Products from Product AND Product Category sitemap when they have the status of "Out of Stock" #6249

Open
Pcosta88 opened this issue Dec 12, 2016 · 26 comments

Comments

@Pcosta88
Copy link
Contributor

Pcosta88 commented Dec 12, 2016

If a user has a product it appears on the sitemap. If that product then sells it will remain on the sitemap until removed manually by the user. To manually remove it, the user will need to mark the page as noindex.

We should include an automatic removal from the sitemap. For example, when a user manually changes the product status to "out of stock" the product is then automatically removed from the sitemap.

screen_shot_2017-01-24_at_1_56_47_pm

@Pcosta88
Copy link
Contributor Author

Please inform the customer of conversation # 164385 when this conversation has been closed.

@SingingBowls
Copy link

As the default setting, excluding "out of stock" is probably best for most stores.

In store management there are two kinds of "out of stocks", temporary and permanent. Woocommerce does not provide a way to distinguish between them.

√ "enable stock management" in the inventory section of product files automatically sets products with stock quantity =0 to "out of stock" as they sell. This works fine for products that sell out and never come back. Stores selling unique or quantity limited stock use this as do stores who do not want to disapoint customers with unavailable items.

Stores wishing to continue to keep products with zero inventory on their sitemap because they are only temporarily unavailable could un√ "enable stock management". Some stores do this. Others do not because unavailable products will appear on their website.

So you might want to make this an option on the post types tab for those stores wanting to continue to list items they don't currently have.

Even if you don't make it an option many stores will benefit by having the products sitemap smart enough to exclude out of stocks.

@Pcosta88 Pcosta88 changed the title [Feature Request] Remove WooCommerce Products from the sitemap as they sell [Feature Request] Remove WooCommerce Products from Product sitemap when they have the status of "Out of Stock" Jan 24, 2017
@Pcosta88
Copy link
Contributor Author

Please inform the customer of conversation # 172985 when this conversation has been closed.

@SingingBowls
Copy link

Does this mean remove from sitemap when status changes to out of stock is now on your programming agenda? When do you expect it to be implemented?

@Pcosta88
Copy link
Contributor Author

Pcosta88 commented Jan 26, 2017

@SingingBowls At this moment it is just a request for our developers to consider.

@mugwumpr
Copy link

This would totally rock for our used bookstore. We have 169K+ items with only about 33K active at any given time. We never know when we'll need to reactivate a product, depending on what comes in, so removing the records completely isn't an option. Needless to say, we get a lot of 404 errors and Google currently hates us.

If you're counting votes in favour, please include mine.

@Djennez
Copy link
Member

Djennez commented Jan 21, 2019

@jono-alderson you seem to have had a very thoroughly explained opinion on a related matter in #6502 . Would you mind having a look at this request? What, do you think, would be the pro's and con's in this?

@SingingBowls
Copy link

SingingBowls commented Jan 21, 2019 via email

@jonoalderson
Copy link

jonoalderson commented Jan 28, 2019

Ooh, interesting stuff!

Two threads here, so picking them apart...

On the 'two types' of 'out of stock' behaviour

This is indeed challenging. I'd really love for a 'permanent' out of stock status to be handled differently (noindex, remove from sitemaps, etc) to a 'temporary' out of stock. We'll have a think about how this might be handled; it might be a space for an additional WooCommerce addon/plugin/setting.

On product deletion / XML sitemaps

I'm not sure how/why a deleted product would still remain in the sitemap - if it's been deleted, there's no page/URL to show. It sounds like perhaps your deletion process isn't actually deleting the products/pages, or, we have an issue with how your sitemaps are being generated.

@mugwumpr
Copy link

mugwumpr commented Jan 28, 2019 via email

@SingingBowls
Copy link

SingingBowls commented Jan 28, 2019 via email

@jonoalderson
Copy link

Thanks for the feedback. We'll have a look at this, and consider options and ideas!

@Pcosta88 Pcosta88 changed the title [Feature Request] Remove WooCommerce Products from Product sitemap when they have the status of "Out of Stock" [Feature Request] Remove WooCommerce Products from Product AND Product Category sitemap when they have the status of "Out of Stock" Mar 14, 2019
@Pcosta88
Copy link
Contributor Author

Please inform the customer of conversation # 483986 when this conversation has been closed.

@SingingBowls
Copy link

SingingBowls commented Mar 14, 2019 via email

@Pcosta88
Copy link
Contributor Author

Pcosta88 commented Mar 14, 2019

@SingingBowls Hi, We mean that when we have a resolution for the issue we will contact the customer who has ticket number 483986.

@SingingBowls
Copy link

SingingBowls commented Mar 14, 2019 via email

@Pcosta88
Copy link
Contributor Author

@SingingBowls The issue is still an open one. No resolution or decision has been made on it.

@mayada-ibrahim
Copy link

Please inform the customer of conversation # 558765 when this conversation has been closed.

@Pcosta88
Copy link
Contributor Author

Please inform the customer of conversation # 633989 when this conversation has been closed.

@suascat
Copy link

suascat commented Jul 28, 2021

Please inform the customer of conversation # 775158 when this conversation has been closed.

@ogodoabiola
Copy link

Please inform the customer of conversation # 845391 when this conversation has been closed.

@monbauza
Copy link

monbauza commented Dec 8, 2021

On my test site, I've been able to exclude out-of-stock products from the sitemap using the filter below:

add_filter( 'wpseo_sitemap_entry', 'custom_exclude_from_xml_sitemap', 10, 3 );
function custom_exclude_from_xml_sitemap( $url, $type, $object ) {
	if ($object->post_type == 'product') {
		$product = wc_get_product( $object );
		if (!$product->is_in_stock())
			return false;
	}
return $url;
}

@suascat
Copy link

suascat commented Mar 3, 2022

Please inform the customer of conversation # 873216 when this conversation has been closed.

@maybellyne
Copy link

Please inform the customer of conversation # 879051 when this conversation has been closed.

@Yvonne-Palanca
Copy link

Please inform customer #989361 when this conversation has been closed.

@Stason077
Copy link

On my test site, I've been able to exclude out-of-stock products from the sitemap using the filter below:

add_filter( 'wpseo_sitemap_entry', 'custom_exclude_from_xml_sitemap', 10, 3 );
function custom_exclude_from_xml_sitemap( $url, $type, $object ) {
	if ($object->post_type == 'product') {
		$product = wc_get_product( $object );
		if (!$product->is_in_stock())
			return false;
	}
return $url;
}

Thank you. Your code worked!
Perhaps you have similar code, for conversion an "noindex" for "out of stock" products?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests