How to add custom attribute to all outofstock and all instock products automatically?

WooCommerce already saves a custom metadata called _stock_status.
This metadata can have these values:

instock
outofstock
onbackorder

You don’t need to create your own metadata as that would be redundant and more difficult to keep in sync with WooCommerce data.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)