You are here

public function StoreHandler::getStore in Mailchimp E-Commerce 8

@inheritdoc

Overrides StoreHandlerInterface::getStore

File

src/StoreHandler.php, line 13

Class

StoreHandler
Store handler.

Namespace

Drupal\mailchimp_ecommerce

Code

public function getStore($store_id) {
  $store = NULL;
  try {

    /* @var \Mailchimp\MailchimpEcommerce $mc_ecommerce */
    $mc_ecommerce = mailchimp_get_api_object('MailchimpEcommerce');
    $store = $mc_ecommerce
      ->getStore($store_id);
  } catch (\Exception $e) {
    if ($e
      ->getCode() == 404) {

      // Store doesn't exist; no need to log an error.
    }
    else {
      mailchimp_ecommerce_log_error_message('Unable to get store: ' . $e
        ->getMessage());
      drupal_set_message($e
        ->getMessage(), 'error');
    }
  }
  return $store;
}