我在数据库中看到我的链接通常位于:
http://www.voomka.com/product/audio-and-video/samsung-ua55hu7000u-uhd-series-7-led-tv/
在数据库中,仅显示samsung-ua55hu7000u-uhd-series-7-led-tv
在“post\\u name”字段中。这意味着还有其他一些逻辑可以推导出完整的路径。我需要所有的“产品”职位,完整的路径和型号。有没有一种简单的方法来提取这个?
我在数据库中看到我的链接通常位于:
http://www.voomka.com/product/audio-and-video/samsung-ua55hu7000u-uhd-series-7-led-tv/
在数据库中,仅显示samsung-ua55hu7000u-uhd-series-7-led-tv
在“post\\u name”字段中。这意味着还有其他一些逻辑可以推导出完整的路径。我需要所有的“产品”职位,完整的路径和型号。有没有一种简单的方法来提取这个?
我使用了WooCommerce API和以下代码:
<?php
set_time_limit(0);
// Include the client library
require_once \'class-wc-api-client.php\';
$consumer_key = \'XXXX\'; // Add your own Consumer Key here
$consumer_secret = \'XXXX\'; // Add your own Consumer Secret here
$store_url = \'http://www.example.com/\'; // Add the home URL to the store you want to connect to here
// Initialize the class
$wc_api = new WC_API_Client( $consumer_key, $consumer_secret, $store_url );
$file = \'./dataX.txt\';
if (file_exists($file) ) {
$products = file_get_contents($file);
}
else {
$itemsPerPage = 15;
$page = 0;
$p = $wc_api->get_products(array( \'filter[limit]\' => $itemsPerPage, \'filter[offset]\' => ($page * $itemsPerPage) ) );
$products = array();
while (!empty($p->products)) {
foreach ($p->products as $pppp) {
$products[] = $pppp;
}
$page++;
$p = $wc_api->get_products(array( \'filter[limit]\' => $itemsPerPage, \'filter[offset]\' => ($page * $itemsPerPage) ) );
}
print \'<pre>\';
print sizeof($products).\'----\';
print_r($products);
die();
我有一个场景,其目的是创建可以动态更改的自定义永久链接,例如:如果显示国家信息,则URL应为http://example.com/country-information如果显示特定国家的城市信息,则URL应如下所示http://example.com/country/city-information. 我怎样才能做到这一点?