You are here

public function ProductHandler::buildProductUrl in Mailchimp E-Commerce 8

Creates a URL from a product.

Parameters

Product $product: The Commerce product object.

Return value

string The URL of the product.

Overrides ProductHandlerInterface::buildProductUrl

1 call to ProductHandler::buildProductUrl()
ProductHandler::buildProductVariants in src/ProductHandler.php
Returns product variant data formatted for use with Mailchimp.

File

src/ProductHandler.php, line 332

Class

ProductHandler
Product handler.

Namespace

Drupal\mailchimp_ecommerce

Code

public function buildProductUrl($product) {
  global $base_url;

  // Mailchimp will accept an empty string if no URL is available.
  $full_url = '';
  $url = $product
    ->toURL();
  if (!empty($url)) {
    $full_url = $base_url . $url
      ->toString();
  }
  return $full_url;
}