Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection

Controller::initialize()protectedWC 1.0

Initialize this block type.

  • Register hooks and filters.
  • Set up QueryBuilder, Renderer and HandlerRegistry.

Method of the class: Controller{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->initialize();

Controller::initialize() code WC 9.6.1

protected function initialize() {
	parent::initialize();

	$this->query_builder               = new QueryBuilder();
	$this->renderer                    = new Renderer();
	$this->collection_handler_registry = new HandlerRegistry();

	// Update query for frontend rendering.
	add_filter(
		'query_loop_block_query_vars',
		array( $this, 'build_frontend_query' ),
		10,
		3
	);

	add_filter(
		'pre_render_block',
		array( $this, 'add_support_for_filter_blocks' ),
		10,
		2
	);

	// Update the query for Editor.
	add_filter( 'rest_product_query', array( $this, 'update_rest_query_in_editor' ), 10, 2 );

	// Extend allowed `collection_params` for the REST API.
	add_filter( 'rest_product_collection_params', array( $this, 'extend_rest_query_allowed_params' ), 10, 1 );
	add_filter( 'render_block_core/post-title', array( $this, 'add_product_title_click_event_directives' ), 10, 3 );

	// Disable client-side-navigation if incompatible blocks are detected.
	add_filter( 'render_block_data', array( $this, 'disable_enhanced_pagination' ), 10, 1 );

	$this->register_core_collections_and_set_handler_store();
}