WC_Product_CSV_Exporter::generate_row_data()
Take a product and generate row data from it for export.
Метод класса: WC_Product_CSV_Exporter{}
Хуки из метода
Возвращает
Массив
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->generate_row_data( $product );
- $product(WC_Product) (обязательный)
- WC_Product object.
Код WC_Product_CSV_Exporter::generate_row_data() WC Product CSV Exporter::generate row data WC 9.3.3
protected function generate_row_data( $product ) { $columns = $this->get_column_names(); $row = array(); foreach ( $columns as $column_id => $column_name ) { $column_id = strstr( $column_id, ':' ) ? current( explode( ':', $column_id ) ) : $column_id; $value = ''; // Skip some columns if dynamically handled later or if we're being selective. if ( in_array( $column_id, array( 'downloads', 'attributes', 'meta' ), true ) || ! $this->is_column_exporting( $column_id ) ) { continue; } if ( has_filter( "woocommerce_product_export_{$this->export_type}_column_{$column_id}" ) ) { // Filter for 3rd parties. $value = apply_filters( "woocommerce_product_export_{$this->export_type}_column_{$column_id}", '', $product, $column_id ); } elseif ( is_callable( array( $this, "get_column_value_{$column_id}" ) ) ) { // Handle special columns which don't map 1:1 to product data. $value = $this->{"get_column_value_{$column_id}"}( $product ); } elseif ( is_callable( array( $product, "get_{$column_id}" ) ) ) { // Default and custom handling. $value = $product->{"get_{$column_id}"}( 'edit' ); } if ( 'description' === $column_id || 'short_description' === $column_id ) { $value = $this->filter_description_field( $value ); } $row[ $column_id ] = $value; } $this->prepare_downloads_for_export( $product, $row ); $this->prepare_attributes_for_export( $product, $row ); $this->prepare_meta_for_export( $product, $row ); /** * Allow third-party plugins to filter the data in a single row of the exported CSV file. * * @since 3.1.0 * * @param array $row An associative array with the data of a single row in the CSV file. * @param WC_Product $product The product object correspnding to the current row. * @param WC_Product_CSV_Exporter $exporter The instance of the CSV exporter. */ return apply_filters( 'woocommerce_product_export_row_data', $row, $product, $this ); }