Automattic\WooCommerce\Internal\ProductFeed\Integrations\POSCatalog

POSIntegration{}WC 10.5.0└─ IntegrationInterface

POS Catalog Integration

Хуков нет.

Использование

$POSIntegration = new POSIntegration();
// use class methods

Методы

  1. public activate()
  2. public create_feed()
  3. public deactivate()
  4. public get_feed_validator()
  5. public get_id()
  6. public get_product_feed_query_args()
  7. public get_product_mapper()
  8. public init( Container $container )
  9. public register_hooks()
  10. public rest_api_init()

Список изменений

С версии 10.5.0 Введена.

Код POSIntegration{} WC 10.5.2

class POSIntegration implements IntegrationInterface {
	/**
	 * Container instance.
	 *
	 * @var Container
	 */
	private Container $container;

	/**
	 * Dependency injector.
	 *
	 * @param Container $container Dependency container.
	 * @internal
	 */
	final public function init( Container $container ): void {
		$this->container = $container;
	}

	/**
	 * {@inheritdoc}
	 */
	public function get_id(): string {
		return 'pos';
	}

	/**
	 * {@inheritdoc}
	 */
	public function get_product_feed_query_args(): array {
		return array(
			'type'      => array( 'simple', 'variable', 'variation' ),
			// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
			'tax_query' => array(
				array(
					'taxonomy' => 'pos_product_visibility',
					'field'    => 'slug',
					'terms'    => 'pos-hidden',
					'operator' => 'NOT IN',
				),
			),
		);
	}

	/**
	 * {@inheritdoc}
	 */
	public function register_hooks(): void {
		add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
		$this->container->get( AsyncGenerator::class )->register_hooks();
		$this->container->get( POSProductVisibilitySync::class )->register_hooks();
	}

	/**
	 * Initialize the REST API.
	 *
	 * @return void
	 */
	public function rest_api_init(): void {
		// Only load the controller when necessary.
		$this->container->get( ApiController::class )->register_routes();
	}

	/**
	 * {@inheritdoc}
	 */
	public function activate(): void {
		// At the moment, there are no activation steps for the POS catalog.
	}

	/**
	 * {@inheritdoc}
	 */
	public function deactivate(): void {
		// At the moment, there are no deactivation steps for the POS catalog.
	}

	/**
	 * {@inheritdoc}
	 */
	public function create_feed(): FeedInterface {
		return new JsonFileFeed( 'pos-catalog-feed' );
	}

	/**
	 * {@inheritdoc}
	 */
	public function get_product_mapper(): ProductMapper {
		return $this->container->get( ProductMapper::class );
	}

	/**
	 * {@inheritdoc}
	 */
	public function get_feed_validator(): FeedValidatorInterface {
		return $this->container->get( FeedValidator::class );
	}
}