Automattic\WooCommerce\Internal\ProductFeed\Storage

JsonFileFeed::add_entrypublicWC 1.0

Add an entry to the feed.

Method of the class: JsonFileFeed{}

No Hooks.

Returns

null. Nothing (null).

Usage

$JsonFileFeed = new JsonFileFeed();
$JsonFileFeed->add_entry( $entry ): void;
$entry(array) (required)
The entry to add.

JsonFileFeed::add_entry() code WC 10.9.4

public function add_entry( array $entry ): void {
	if ( ! is_resource( $this->file_handle ) ) {
		return;
	}

	$json = wp_json_encode( $entry );
	if ( false === $json ) {
		return;
	}

	if ( $this->entry_count > 0 ) {
		fwrite( $this->file_handle, ',' );
	}

	fwrite( $this->file_handle, $json );
	++$this->entry_count;
}