Attributes lookup-table (WooCommerce): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
Regel 169: Regel 169:
 
cd ~/applications/example_be/public_html
 
cd ~/applications/example_be/public_html
 
#
 
#
echo " ${PWD}:"
+
echo ""
 +
echo ""
 +
echo "######################################## ${PWD}:"
 
wp option list --search=woocommerce_attribute_lookup_enabled
 
wp option list --search=woocommerce_attribute_lookup_enabled
 
wp option update woocommerce_attribute_lookup_enabled no
 
wp option update woocommerce_attribute_lookup_enabled no
Regel 176: Regel 178:
 
cd ~/applications/example_ch/public_html
 
cd ~/applications/example_ch/public_html
 
#
 
#
echo " ${PWD}:"
+
echo ""
 +
echo ""
 +
echo "######################################## ${PWD}:"
 
wp option list --search=woocommerce_attribute_lookup_enabled
 
wp option list --search=woocommerce_attribute_lookup_enabled
 
wp option update woocommerce_attribute_lookup_enabled no
 
wp option update woocommerce_attribute_lookup_enabled no
Regel 183: Regel 187:
 
cd ~/applications/example_fr/public_html
 
cd ~/applications/example_fr/public_html
 
#
 
#
echo " ${PWD}:"
+
echo ""
 +
echo ""
 +
echo "######################################## ${PWD}:"
 
wp option list --search=woocommerce_attribute_lookup_enabled
 
wp option list --search=woocommerce_attribute_lookup_enabled
 
wp option update woocommerce_attribute_lookup_enabled no
 
wp option update woocommerce_attribute_lookup_enabled no
Regel 190: Regel 196:
 
cd ~/applications/example_lu/public_html
 
cd ~/applications/example_lu/public_html
 
#
 
#
echo " ${PWD}:"
+
echo ""
 +
echo ""
 +
echo "######################################## ${PWD}:"
 
wp option list --search=woocommerce_attribute_lookup_enabled
 
wp option list --search=woocommerce_attribute_lookup_enabled
 
wp option update woocommerce_attribute_lookup_enabled no
 
wp option update woocommerce_attribute_lookup_enabled no
Regel 197: Regel 205:
 
cd ~/applications/example_nl/public_html
 
cd ~/applications/example_nl/public_html
 
#
 
#
echo " ${PWD}:"
+
echo ""
 +
echo ""
 +
echo "######################################## ${PWD}:"
 
wp option list --search=woocommerce_attribute_lookup_enabled
 
wp option list --search=woocommerce_attribute_lookup_enabled
 
wp option update woocommerce_attribute_lookup_enabled no
 
wp option update woocommerce_attribute_lookup_enabled no

Versie van 22 jun 2022 19:56

Begin 2022 vond de update plaats naar WooCommerce 6.3. Hierbij werd iets nieuws geïntroduceerd: attribute lookup table, oftewel new product filtering by attributes. Helaas introduceert deze update storingen in webwinkels waarvan ik het beheer doe.

Functionaliteit

New product filtering by attributes verhelpt een aantal bekende tekortkomingen rondom filteren van variable products. Het betreft geen performance-verbetering, enkel het toevoegen van missende functionalteit. Voorbeeld: Van een bepaald t-shirt in je webwinkel heb je 10 stuks blauw en 30 stuks zwart. Tot op heden kon de voorraadpositie niet apart bijgehouden worden voor deze twee varianten, maar enkel voor dit t-shirt-als-geheel. Dat zou nu verbeterd zijn.

Na installatie van deze update, vindt er een database-upgrade plaats, waarbij een nieuwe tabel wp_wc_product_attributes_lookup wordt aangemaakt en gevuld [1]:

What’s going to happen after I upgrade to/install WooCommerce 6.3?
A database migration will kick in. This will create the new product
attributes lookup table and will trigger a recursive scheduled action
that will fill it; you can verify that this is the case by opening
the WooCommerce tools page (WooCommerce – Status – Tools), you should
see a new entry titled “Regenerate the product attributes lookup 
table” with a disabled button that displays a number:

The number indicates how many products have been processed so far
(10 products are processed in each batch by default, more on that
later). Note that “processed” in this context means that the
appropriate entries will have been created in the new lookup table. 
From the point of view of the products themselves, this is a read-only
process and no modifications will happen whatsoever for any product.

Once the process has finished the button will appear as enabled and
its label will be “Regenerate”. But more interestingly, a new 
settings section will become available as well.

Once the initial database migration has finished a new “Advanced”
section will appear in the product settings tab (WooCommerce – 
Settings – Products – Advanced) with a couple of options related to
this new feature:

“Use the product attributes lookup table for catalog filtering”
instructs WooCommerce to effectively use the new lookup table for
the shop catalog display and filtering, it will have been enabled
automatically after the database migration finishes but you can enable
and disable it at will (when disabled, the posts table will be used 
instead, as it was the case when the lookup table wasn’t available).

“Update the table directly upon product changes, instead of scheduling
a deferred update” determines how the lookup table will be updated
whenever a product is created or updated: when enabled, the update
will happen immediately; otherwise, the action scheduler will do the 
update job some (short) time after the product is created or updated.

Important: WooCommerce will always create or update the appropriate
entry in the lookup table whenever a product is created or updated,
even when the “Enable table usage” setting is off. This is necessary to
guarantee data consistency in all cases, regardless of whether the
table usage is set on or off.
Je vindt de instelling hiero: wp-admin » WooCommerce » Settings » Products » Advanced » Use the product attributes lookup table for catalog filtering
Product lookup tables » Regenerate - Deze knop zit vrijwel onderaan het scherm. In dit geval staat de teller op 11.890. Dat heeft ca. 6 uur geduurd
Status » System status: Dit zou de betreffende tabel zijn
Via de WP-CLI kun je regenereren van de tabel starten middels wp wc tool run regenerate_product_attributes_lookup_table. De feedback lijkt te suggereren dat het commando echter niet direct wordt uitgevoerd, maar ergens in een wachtrij belandt

Het probleem

Dit is mijn gebruikelijke ervaring met deze functionaliteit: Producten kunnen niet meer gevonden worden op bepaalde attributen (kenmerken)

Aanvullende gegevens & acties

  • Transients verwijderen na regeneration van de tabel (wp transient delete --all), maakt geen verschil
  • Regeneration duurt al snel een halve dag. Gedurende die periode lijkt het systeem te werken, maar dat is niet zo: Het staat uitgeschakeld gedurende deze periode. Naderhand wordt het automatisch ingeschakeld, en blijkt het niet te werken (zie casussen hieronder)
  • Zou zoiets als product regeneration oftewel zoiets alls product-openen-en-opnieuw-opslaan het probleem kunnen verhelpen?

Oorzaak

Vermoedelijk een bug: https://github.com/woocommerce/woocommerce/issues/27419

Oplossing

Er lijkt geen gemakkelijke truuk te zijn om dit op te lossen. Er is wel een practische oplossing: Deze functionaliteit uitschakelen, want het wordt toch niet gebruikt.

Hoe je dit op verschillende manieren kunt doen:

Webinterface

wp-admin » WooCommerce » Settings » Products » Advanced » Enable table usage: Uncheck

SQL

select
   *
from
   wp_options
where
   option_name = "woocommerce_attribute_lookup_enabled";

WP-CLI

Uitlezen:

$ wp option list --search=woocommerce_attribute_lookup_enabled

+--------------------------------------+--------------+
| option_name                          | option_value |
+--------------------------------------+--------------+
| woocommerce_attribute_lookup_enabled | yes          |
+--------------------------------------+--------------+

Uitzetten:

$ wp option update woocommerce_attribute_lookup_enabled no

Success: Updated 'woocommerce_attribute_lookup_enabled' option.

Casus: Drie shops (mei 2022)

Dit betreft drie webwinkels: example.nl, example.nz en example.pl:

Probleem

Shoppagina voor merk AXG bevat geen producten

Aanvullende gegevens & acties

  • Tabel wp_wc_product_attributes_lookup bevat oorspronkelijk 5.346 regels
  • wp-admin » WooCommerce » Products » Advanced » Enable table usage: Actief
  • Transients verwijderd: wp transient delete --all - Geen verschil
  • Update database toegepast ([2]) - Geen verschil
  • wp-admin » WooCommerce » Status » Tools » Regenerate the product attributes lookup table: Regenerate: Probleem verdwenen, vermoedelijk omdat de tabel niet wordt gebruikt gedurende regenereren.
  • [3]: Update database; Regenerate product lookup table; Regenerate product attribute lookup table; Clear transients

De volgende dag was het probleem terug.

Oplossing

Bovengenoemd WP-CLI commando toegepast binnen dit script:

#!/bin/bash
#
################################################################################
# Disable attribute lookup table - For all sites at server dvb12
################################################################################
# 
#
# Sources
########################################
#
# * sftp://123.456.112.52/home/jeroen/projects/150-create-accounts-for-Steven-2022.04
# * https://wiki.devliegendebrigade.nl/Attributes_lookup-table_(WooCommerce)
#
#
# History
########################################
#
# * 2022.05.14: Created
# * 2022.06.22: Updated to include echo PWD & setting before updaing
#
#
cd ~/applications/example_be/public_html
	#
	echo ""
	echo ""
	echo "######################################## ${PWD}:"
	wp option list --search=woocommerce_attribute_lookup_enabled
	wp option update woocommerce_attribute_lookup_enabled no


cd ~/applications/example_ch/public_html
	#
	echo ""
	echo ""
	echo "######################################## ${PWD}:"
	wp option list --search=woocommerce_attribute_lookup_enabled
	wp option update woocommerce_attribute_lookup_enabled no


cd ~/applications/example_fr/public_html
	#
	echo ""
	echo ""
	echo "######################################## ${PWD}:"
	wp option list --search=woocommerce_attribute_lookup_enabled
	wp option update woocommerce_attribute_lookup_enabled no


cd ~/applications/example_lu/public_html
	#
	echo ""
	echo ""
	echo "######################################## ${PWD}:"
	wp option list --search=woocommerce_attribute_lookup_enabled
	wp option update woocommerce_attribute_lookup_enabled no


cd ~/applications/example_nl/public_html
	#
	echo ""
	echo ""
	echo "######################################## ${PWD}:"
	wp option list --search=woocommerce_attribute_lookup_enabled
	wp option update woocommerce_attribute_lookup_enabled no

Bronnen