Markus Michalski FAQ

Marketplace Redirect: Extending

Extending Marketplace Redirect: adding another marketplace through a URL builder, replaceable services and backward compatibility.

Deutsche Version

Back to overview

Marketplace Redirect: Extending

This documentation always describes the latest published version.

Adding another marketplace

The URL is built from the reference by one service per marketplace, each implementing MarketplaceUrlBuilderInterface. The resolver collects all services tagged mmd_sylius_marketplace_redirect.url_builder and asks them in turn which one supports the type.

Method Purpose
supports(MarketplaceType $type) Whether this builder handles the type
isValidReference(string $reference) Whether the reference is valid for this marketplace
build(string $reference, ?string $region = null) Builds the URL, throws \InvalidArgumentException for an invalid reference
services:
    App\Marketplace\MyMarketplaceUrlBuilder:
        tags: ['mmd_sylius_marketplace_redirect.url_builder']

The marketplace type is an enum of the plugin (MarketplaceType with the cases amazon and shopware_store) and cannot be extended through configuration. A third marketplace needs a new enum case, which means a change to the plugin itself, and a matching button in the shop template.

Replaceable services

Service or interface Purpose
MarketplaceRedirectProviderInterface Returns the redirect for a product. Replaceable through a service alias
mmd_sylius_marketplace_redirect.channel_settings_repository Public service for the channel settings, so tests and the host can fetch it
sylius_twig_hooks.renderer.hookable Decorated by the plugin and can be decorated further by the host
ChannelSettingsRepositoryInterface, ProductMarketplaceLinkRepositoryInterface Repositories for channel settings and links, reachable through an autowiring alias
mmd_sylius_marketplace_redirect_plugin.marketplace_redirect_settings, mmd_sylius_marketplace_redirect_plugin.product_marketplace_link The two entities registered as Sylius resources
mmd_sylius_marketplace_redirect_plugin_admin_marketplace_redirect_settings Grid ID of the settings list, extensible through sylius_grid

Backward compatibility

The AdminMenuListener class is marked @internal: constructors and internals may change in a minor release. When extending, rely on the interfaces and tags named above.