{"id":401651,"date":"2024-06-29T16:00:13","date_gmt":"2024-06-29T16:00:13","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=401651"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-29T16:00:13","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=401651","title":{"rendered":"<span>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c CSV-\u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0430 custom-\u043f\u043e\u0441\u0442\u043e\u0432 \u0432 \u0442\u043e\u0432\u0430\u0440\u044b WooCoommerc\u2019\u0430<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0435\u0440\u0435\u0434\u0435\u043b\u044b\u0432\u0430\u0435\u043c \u0442\u0443\u0442 \u043e\u0434\u0438\u043d \u0441\u0442\u0430\u0440\u044b\u0439 WordPress-\u0441\u0430\u0439\u0442 \u0432 \u043d\u043e\u0432\u044b\u0439 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 WooCommerce. \u041d\u0430 \u0441\u0442\u0430\u0440\u043e\u043c \u0441\u0430\u0439\u0442\u0435 \u043c\u043d\u043e\u0433\u043e \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 custom\u2019\u043d\u044b\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u0441 \u0437\u0430\u043a\u0430\u0437\u043e\u043c \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u043e\u0440\u043c\u0443 Contact Form 7. \u0410 \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0441 WooCommerce. \u041f\u0438\u0441\u0430\u0442\u044c \u0433\u0440\u0430\u0431\u0431\u0435\u0440 \u043f\u0440\u044f\u043c\u043e \u0441 \u0441\u0430\u0439\u0442\u0430 \u043d\u0435\u0442 \u0436\u0435\u043b\u0430\u043d\u0438\u044f, \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u0411\u0414 \u0442\u043e\u0436\u0435 \u0432\u043e\u0437\u043d\u044f \u043b\u0438\u0448\u043d\u044f\u044f, \u0440\u0435\u0448\u0438\u043b\u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u043e\u0432\u0430\u0440\u044b \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 CSV, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u0435\u0433\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 \u0440\u043e\u0434\u043d\u043e\u0439 \u0438\u043c\u043f\u043e\u0440\u0442 \u0442\u043e\u0432\u0430\u0440\u043e\u0432 WooCommerce.<\/p>\n<pre><code class=\"php\">&lt;?php  if ($_GET['product_export']) {  add_action('init', function() {   \/\/ \u0442\u043e\u0432\u0430\u0440\u044b \u043d\u0430 \u0441\u0442\u0430\u0440\u043e\u043c \u0441\u0430\u0439\u0442\u0435 - \u044d\u0442\u043e \u043f\u043e\u0441\u0442\u044b \u0441 \u0442\u0438\u043f\u043e\u043c: tovary $_products = get_posts(array( 'numberposts' => -1, 'post_type' => 'tovary', ));  if (is_array($_products) and count($_products)) { foreach ($_products as $_product) {  $line['ID'] = $_product->ID; $line['\u0418\u043c\u044f'] = $_product->post_title; $line['\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435'] = get_the_post_thumbnail_url($_product->ID, 'full'); $line['\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435'] = $_product->post_content;  $_meta = get_metadata('post', $_product->ID);  if (is_array($_meta['mwpf_technical']) and count($_meta['mwpf_technical']) and count($_meta['mwpf_technical'][0])) {   \/\/$line['meta'] = var_export($_meta, true ); \/\/ \u0440\u0430\u0441\u043a\u043e\u043c\u0435\u043d\u0442\u0438\u0442\u044c \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0447\u0442\u043e \u0442\u0430\u043c =)  $_price = (int) str_replace(' ', '', $_meta['mwpf_action_one'][0]);  $line['\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0446\u0435\u043d\u0430'] = $_price ? $_price : ''; \/\/ \u0447\u0442\u043e\u0431\u044b \u0446\u0435\u043d\u0430 \u043d\u0435 \u0431\u044b\u043b\u0430 0 \u0432 WooCommerce \u0434\u043b\u044f \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u0431\u0435\u0437 \u0446\u0435\u043d\u044b \u043d\u0430 \u0441\u0442\u0430\u0440\u043e\u043c \u0441\u0430\u0439\u0442\u0435  \/\/ \u0442\u0430\u043c \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u043c\u0435\u0442\u0430-\u043f\u043e\u043b\u044f ( \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f WordPress \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439 ) $line['\u041c\u0435\u0442\u0430: mwpf_file'] = $_meta['mwpf_file'][0]; $line['\u041c\u0435\u0442\u0430: mwpf_file_name'] = $_meta['mwpf_file_name'][0];   \/\/ \u0430 \u0442\u0430\u043a \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0438\u0437 HTML-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432 \u043c\u0435\u0442\u0430-\u043f\u043e\u043b\u0435 \u0442\u043e\u0432\u0430\u0440\u0430 preg_match_all('|&lt;td>(.*?)&lt;\/td>&lt;td>(.*?)&lt;\/td>&lt;\/tr>|is', $_meta['mwpf_technical'][0], $buff);  \/\/$line['dfsd'] = '&lt;pre>'. strip_tags(var_export( $buff, true)) . '&lt;\/pre>'; \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430  \/\/ \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u0430\u043c \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f, \u043d\u043e \u0432\u0434\u0440\u0443\u0433 \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0445\u043e\u0436\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f  if ( is_array($buff[1]) and count($buff[1]) ) { foreach ($buff[1] as $key => $_value) { $_name = trim(strip_tags($_value)); if ($_name == '') continue; if (is_numeric($_name)) continue; $__value = trim(strip_tags($buff[2][$key])); if ( $__value == '+') $__value = '\u0434\u0430'; $atts[$line['ID']][$_name] = $__value; $atts_names[$_name] = $_name; } }  if ( is_array($atts_names) and count($atts_names) ) { foreach($atts_names as $_name) { if (isset($atts[$line['ID']][$_name])) { $line[$_name] = $atts[$line['ID']][$_name]; } else { $line[$_name] = ''; } } }  \/\/$line['\u0410\u0442\u0440\u0438\u0431\u0443\u0442\u044b'] = var_export($buff, true); \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 }  $headers = array_merge( (array) $headers, array_combine(array_keys($line), array_keys($line)) );  $lines[] = $line; } }  if (is_array($lines) and count($lines)) {  \/\/ \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043b\u0438 \u043c\u044b \u0432\u0441\u0451 \u0441\u0434\u0435\u043b\u0430\u043b\u0438:  echo '&lt;table border=\"1\">'; echo '&lt;tr>'; foreach ( $headers as $_name ) { echo '&lt;th>' . $_name . '&lt;\/th>'; } echo '&lt;\/tr>';  foreach ($lines as $_line) { echo '&lt;tr>'; foreach ($headers as $_name) { echo '&lt;td>' . $_line[$_name] . '&lt;\/td>'; } echo '&lt;\/tr>'; }  echo '&lt;\/table>';    \/\/ \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f CSV-\u0444\u0430\u0439\u043b\u0430: $line = array(); foreach ( $headers as $_name ) { if (isset($atts_names[$_name])) { $i++; $line[] = \"\u0418\u043c\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 $i\"; $line[] = \"\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435(-\u044f) \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430(-\u043e\u0432) $i\"; $line[] = \"\u0412\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 $i\"; $line[] = \"\u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 $i\"; } else { $line[] = $_name; } } $data[] = $line;  foreach ($lines as $_line) { $line = array(); foreach ($headers as $_name) { if (isset($atts_names[$_name])) { $line[] = $_name; $line[] = $_line[$_name]; $line[] = 1; $line[] = 1; } else { $line[] = $_line[$_name]; } } $data[] = $line; }  \/\/ \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 CSV-\u0444\u0430\u0439\u043b @unlink(__DIR__.'\/export.csv'); $fp = fopen(__DIR__.'\/export.csv', 'w'); foreach ($data as $_fields) {     fputcsv($fp,  $_fields); } fclose($fp);  \/\/ \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 CSV-\u0444\u0430\u0439\u043b echo '&lt;hr>&lt;a href=\"' . get_template_directory_uri() . '\/export.csv\">\u0421\u043a\u0430\u0447\u0430\u0442\u044c CSV&lt;\/a>';  }  exit(); }); }<\/code><\/pre>\n<p>\u041d\u0435 \u0442\u043e\u0440\u043e\u043f\u0438\u0442\u0435\u0441\u044c \u043e\u0445\u0430\u0442\u044c \u0438 \u0430\u0445\u0430\u0442\u044c \u043e\u0442 \u0431\u0435\u0437\u0443\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u0417\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0442\u043e\u0432\u0430\u0440\u044b \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0441\u0430\u0439\u0442 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0432 WooCommerce.<\/p>\n<p>\u0422\u0430\u043c \u043c\u043d\u043e\u0433\u043e \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0443 \u0432\u0430\u0441 \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0438 \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041a\u043e\u0434 \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u044f\u043c\u043e \u0432 functions.php \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0442\u0435\u043c\u044b \u0438 \u0432\u044b\u0437\u0432\u0430\u043d \u0447\u0435\u0440\u0435\u0437 \u0432\u0430\u0448_\u0441\u0430\u0439\u0442\/product_export?=1. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u0435\u0440\u0435\u0434 \u0432\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 CSV-\u0444\u0430\u0439\u043b, \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0434\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0432 WooCommerce. <\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438 WooCommerce \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u043f\u0440\u044f\u043c\u043e \u0433\u0440\u0443\u0437\u0438\u0442 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430, \u0447\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u0430 \u0435\u0441\u043b\u0438 \u0437\u0434\u0435\u0441\u044c:<\/p>\n<pre><code class=\"powershell\">$line['\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435'] = get_the_post_thumbnail_url($_product->ID, 'full');<\/code><\/pre>\n<p> \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0441\u044b\u043b\u043e\u043a \u043a\u043e \u0432\u0441\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c \u0442\u043e\u0432\u0430\u0440\u0430, \u0442\u043e\u0433\u0434\u0430 WooCommerce \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442 \u0438\u0445 \u0432\u0441\u0435: \u043f\u043e \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0444\u043e\u0442\u043e \u0442\u043e\u0432\u0430\u0440\u0430, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0439\u0434\u0443\u0442 \u0432 \u0433\u0430\u043b\u0435\u0440\u0435\u044e.<\/p>\n<p>\u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u043e\u0431\u0440\u0430\u043b\u0438 URL-\u0430\u0434\u0440\u0435\u0441\u0430 \u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c \u0442\u043e\u0432\u0430\u0440\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 $images<\/p>\n<pre><code class=\"php\">if (is_array($images) and count($images)) { $line['\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435'] = implode(',', $images); }<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/579700\/\"> https:\/\/habr.com\/ru\/articles\/579700\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0435\u0440\u0435\u0434\u0435\u043b\u044b\u0432\u0430\u0435\u043c \u0442\u0443\u0442 \u043e\u0434\u0438\u043d \u0441\u0442\u0430\u0440\u044b\u0439 WordPress-\u0441\u0430\u0439\u0442 \u0432 \u043d\u043e\u0432\u044b\u0439 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 WooCommerce. \u041d\u0430 \u0441\u0442\u0430\u0440\u043e\u043c \u0441\u0430\u0439\u0442\u0435 \u043c\u043d\u043e\u0433\u043e \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 custom\u2019\u043d\u044b\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u0441 \u0437\u0430\u043a\u0430\u0437\u043e\u043c \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u043e\u0440\u043c\u0443 Contact Form 7. \u0410 \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0441 WooCommerce. \u041f\u0438\u0441\u0430\u0442\u044c \u0433\u0440\u0430\u0431\u0431\u0435\u0440 \u043f\u0440\u044f\u043c\u043e \u0441 \u0441\u0430\u0439\u0442\u0430 \u043d\u0435\u0442 \u0436\u0435\u043b\u0430\u043d\u0438\u044f, \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u0411\u0414 \u0442\u043e\u0436\u0435 \u0432\u043e\u0437\u043d\u044f \u043b\u0438\u0448\u043d\u044f\u044f, \u0440\u0435\u0448\u0438\u043b\u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u043e\u0432\u0430\u0440\u044b \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 CSV, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u0435\u0433\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 \u0440\u043e\u0434\u043d\u043e\u0439 \u0438\u043c\u043f\u043e\u0440\u0442 \u0442\u043e\u0432\u0430\u0440\u043e\u0432 WooCommerce.<\/p>\n<pre><code class=\"php\">&lt;?php  if ($_GET['product_export']) {  add_action('init', function() {   \/\/ \u0442\u043e\u0432\u0430\u0440\u044b \u043d\u0430 \u0441\u0442\u0430\u0440\u043e\u043c \u0441\u0430\u0439\u0442\u0435 - \u044d\u0442\u043e \u043f\u043e\u0441\u0442\u044b \u0441 \u0442\u0438\u043f\u043e\u043c: tovary $_products = get_posts(array( 'numberposts' => -1, 'post_type' => 'tovary', ));  if (is_array($_products) and count($_products)) { foreach ($_products as $_product) {  $line['ID'] = $_product->ID; $line['\u0418\u043c\u044f'] = $_product->post_title; $line['\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435'] = get_the_post_thumbnail_url($_product->ID, 'full'); $line['\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435'] = $_product->post_content;  $_meta = get_metadata('post', $_product->ID);  if (is_array($_meta['mwpf_technical']) and count($_meta['mwpf_technical']) and count($_meta['mwpf_technical'][0])) {   \/\/$line['meta'] = var_export($_meta, true ); \/\/ \u0440\u0430\u0441\u043a\u043e\u043c\u0435\u043d\u0442\u0438\u0442\u044c \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0447\u0442\u043e \u0442\u0430\u043c =)  $_price = (int) str_replace(' ', '', $_meta['mwpf_action_one'][0]);  $line['\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0446\u0435\u043d\u0430'] = $_price ? $_price : ''; \/\/ \u0447\u0442\u043e\u0431\u044b \u0446\u0435\u043d\u0430 \u043d\u0435 \u0431\u044b\u043b\u0430 0 \u0432 WooCommerce \u0434\u043b\u044f \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u0431\u0435\u0437 \u0446\u0435\u043d\u044b \u043d\u0430 \u0441\u0442\u0430\u0440\u043e\u043c \u0441\u0430\u0439\u0442\u0435  \/\/ \u0442\u0430\u043c \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u043c\u0435\u0442\u0430-\u043f\u043e\u043b\u044f ( \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f WordPress \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439 ) $line['\u041c\u0435\u0442\u0430: mwpf_file'] = $_meta['mwpf_file'][0]; $line['\u041c\u0435\u0442\u0430: mwpf_file_name'] = $_meta['mwpf_file_name'][0];   \/\/ \u0430 \u0442\u0430\u043a \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0438\u0437 HTML-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432 \u043c\u0435\u0442\u0430-\u043f\u043e\u043b\u0435 \u0442\u043e\u0432\u0430\u0440\u0430 preg_match_all('|&lt;td>(.*?)&lt;\/td>&lt;td>(.*?)&lt;\/td>&lt;\/tr>|is', $_meta['mwpf_technical'][0], $buff);  \/\/$line['dfsd'] = '&lt;pre>'. strip_tags(var_export( $buff, true)) . '&lt;\/pre>'; \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430  \/\/ \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u0430\u043c \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f, \u043d\u043e \u0432\u0434\u0440\u0443\u0433 \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0445\u043e\u0436\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f  if ( is_array($buff[1]) and count($buff[1]) ) { foreach ($buff[1] as $key => $_value) { $_name = trim(strip_tags($_value)); if ($_name == '') continue; if (is_numeric($_name)) continue; $__value = trim(strip_tags($buff[2][$key])); if ( $__value == '+') $__value = '\u0434\u0430'; $atts[$line['ID']][$_name] = $__value; $atts_names[$_name] = $_name; } }  if ( is_array($atts_names) and count($atts_names) ) { foreach($atts_names as $_name) { if (isset($atts[$line['ID']][$_name])) { $line[$_name] = $atts[$line['ID']][$_name]; } else { $line[$_name] = ''; } } }  \/\/$line['\u0410\u0442\u0440\u0438\u0431\u0443\u0442\u044b'] = var_export($buff, true); \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 }  $headers = array_merge( (array) $headers, array_combine(array_keys($line), array_keys($line)) );  $lines[] = $line; } }  if (is_array($lines) and count($lines)) {  \/\/ \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043b\u0438 \u043c\u044b \u0432\u0441\u0451 \u0441\u0434\u0435\u043b\u0430\u043b\u0438:  echo '&lt;table border=\"1\">'; echo '&lt;tr>'; foreach ( $headers as $_name ) { echo '&lt;th>' . $_name . '&lt;\/th>'; } echo '&lt;\/tr>';  foreach ($lines as $_line) { echo '&lt;tr>'; foreach ($headers as $_name) { echo '&lt;td>' . $_line[$_name] . '&lt;\/td>'; } echo '&lt;\/tr>'; }  echo '&lt;\/table>';    \/\/ \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f CSV-\u0444\u0430\u0439\u043b\u0430: $line = array(); foreach ( $headers as $_name ) { if (isset($atts_names[$_name])) { $i++; $line[] = \"\u0418\u043c\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 $i\"; $line[] = \"\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435(-\u044f) \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430(-\u043e\u0432) $i\"; $line[] = \"\u0412\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 $i\"; $line[] = \"\u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 $i\"; } else { $line[] = $_name; } } $data[] = $line;  foreach ($lines as $_line) { $line = array(); foreach ($headers as $_name) { if (isset($atts_names[$_name])) { $line[] = $_name; $line[] = $_line[$_name]; $line[] = 1; $line[] = 1; } else { $line[] = $_line[$_name]; } } $data[] = $line; }  \/\/ \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 CSV-\u0444\u0430\u0439\u043b @unlink(__DIR__.'\/export.csv'); $fp = fopen(__DIR__.'\/export.csv', 'w'); foreach ($data as $_fields) {     fputcsv($fp,  $_fields); } fclose($fp);  \/\/ \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 CSV-\u0444\u0430\u0439\u043b echo '&lt;hr>&lt;a href=\"' . get_template_directory_uri() . '\/export.csv\">\u0421\u043a\u0430\u0447\u0430\u0442\u044c CSV&lt;\/a>';  }  exit(); }); }<\/code><\/pre>\n<p>\u041d\u0435 \u0442\u043e\u0440\u043e\u043f\u0438\u0442\u0435\u0441\u044c \u043e\u0445\u0430\u0442\u044c \u0438 \u0430\u0445\u0430\u0442\u044c \u043e\u0442 \u0431\u0435\u0437\u0443\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u0417\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0442\u043e\u0432\u0430\u0440\u044b \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0441\u0430\u0439\u0442 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0432 WooCommerce.<\/p>\n<p>\u0422\u0430\u043c \u043c\u043d\u043e\u0433\u043e \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0443 \u0432\u0430\u0441 \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0438 \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041a\u043e\u0434 \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u044f\u043c\u043e \u0432 functions.php \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0442\u0435\u043c\u044b \u0438 \u0432\u044b\u0437\u0432\u0430\u043d \u0447\u0435\u0440\u0435\u0437 \u0432\u0430\u0448_\u0441\u0430\u0439\u0442\/product_export?=1. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u0435\u0440\u0435\u0434 \u0432\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 CSV-\u0444\u0430\u0439\u043b, \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0434\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0432 WooCommerce. <\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438 WooCommerce \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u043f\u0440\u044f\u043c\u043e \u0433\u0440\u0443\u0437\u0438\u0442 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430, \u0447\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u0430 \u0435\u0441\u043b\u0438 \u0437\u0434\u0435\u0441\u044c:<\/p>\n<pre><code class=\"powershell\">$line['\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435'] = get_the_post_thumbnail_url($_product->ID, 'full');<\/code><\/pre>\n<p> \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0441\u044b\u043b\u043e\u043a \u043a\u043e \u0432\u0441\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c \u0442\u043e\u0432\u0430\u0440\u0430, \u0442\u043e\u0433\u0434\u0430 WooCommerce \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442 \u0438\u0445 \u0432\u0441\u0435: \u043f\u043e \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0444\u043e\u0442\u043e \u0442\u043e\u0432\u0430\u0440\u0430, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0439\u0434\u0443\u0442 \u0432 \u0433\u0430\u043b\u0435\u0440\u0435\u044e.<\/p>\n<p>\u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u043e\u0431\u0440\u0430\u043b\u0438 URL-\u0430\u0434\u0440\u0435\u0441\u0430 \u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c \u0442\u043e\u0432\u0430\u0440\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 $images<\/p>\n<pre><code class=\"php\">if (is_array($images) and count($images)) { $line['\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435'] = implode(',', $images); }<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/579700\/\"> https:\/\/habr.com\/ru\/articles\/579700\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-401651","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/401651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=401651"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/401651\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=401651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=401651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=401651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}