Remove customizations to resource types

Last updated on
12 June 2020

See #3105318: Add a public API for aliasing resource type names for the issue that allows renaming resource types.

The Commerce API module renames all Commerce ecosystem entities to remove the commerce_ prefix and pluralize the entity type's name.

The commerce_api.resource_type_build_subscriber service customizes all entity types that have the commerce_ prefix. To remove these customizations and use the normal JSON:API resource type naming from Drupal core, use the following instructions.

Create a service provider to alter the service definitions. Remove the commerce_api.resource_type_build_subscriber service from the service container's definitions.

<?php

namespace Drupal\my_module;

use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;

class MyModuleServiceProvider extends ServiceProviderBase {

  public function alter(ContainerBuilder $container) {
    $container->removeDefinition('commerce_api.resource_type_build_subscriber');
  }

}

You'll now have normal Drupal core behavior, such as /jsonapi/commerce_product/default versus /jsonapi/products/default.

Help improve this page

Page status: No known problems

You can: