我制作了一个从WooCommerce中提取产品的脚本和一个更新WooCommerce中库存的脚本。该店有大约750种母产品,这些母产品下的变体总数约为4500种。我将Automatic的PHP SDK用于WooCommerce。
当我运行我的;“提取产品”;函数将所有产品信息保存在外部数据库中,它将正常运行。但如果15分钟后重新运行脚本,我会收到以下消息:
Fatal error: Uncaught Automattic\\WooCommerce\\HttpClient\\HttpClientException: Error: <p>En kritisk feil har inntruffet på ditt nettsted.</p><p><a href="https://wordpress.org/support/article/debugging-in-wordpress/">Lær mer om feilsøking i WordPress.</a></p> [internal_server_error] in /Applications/XAMPP/xamppfiles/htdocs/portland_integrasjon/wc/inc/HttpClient/HttpClient.php:350 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/portland_integrasjon/wc/inc/HttpClient/HttpClient.php(386): Automattic\\WooCommerce\\HttpClient\\HttpClient->lookForErrors(Object(stdClass)) #1 /Applications/XAMPP/xamppfiles/htdocs/portland_integrasjon/wc/inc/HttpClient/HttpClient.php(422): Automattic\\WooCommerce\\HttpClient\\HttpClient->processResponse() #2 /Applications/XAMPP/xamppfiles/htdocs/portland_integrasjon/wc/inc/Client.php(82): Automattic\\WooCommerce\\HttpClient\\HttpClient->request(\'products\', \'GET\', Array, Array) #3 /Applications/XAMPP/xamppfiles/htdocs/portland_integrasjon/wc/wc-procucts-extract.php(8): Automattic\\WooCommerce\\Client->g in /Applications/XAMPP/xamppfiles/htdocs/portland_integrasjon/wc/inc/HttpClient/HttpClient.php on line 350
错误信息是挪威语,但英语是这样写的:您的网站上发生了严重错误。我使用的API调用;“提取产品”;是:
$products = $woocommerce->get(\'products\', $parameters=[\'per_page\' => 99999]);
$productVariation = $woocommerce->get(\'products/\'.$productId.\'/variations/\'.$child);
如果我再等几分钟,为WooCommerce运行另一个API,我们可以说;更新库存;,然后重新运行“;提取产品“;,一切正常。所以我的问题是:我希望能够重新运行“;“提取产品”;函数多次运行,而无需等待或先运行另一个API命中。
有什么建议吗?