You are here

public function CommerceSmartImporerService::getVariationIdBySku in Commerce Smart Importer 8

Returns variation id by sku.

1 call to CommerceSmartImporerService::getVariationIdBySku()
CommerceSmartImporerService::createSku in src/Plugin/CommerceSmartImporerService.php
Checks sku validity.

File

src/Plugin/CommerceSmartImporerService.php, line 1835
Main Commerce Smart Importer Service.

Class

CommerceSmartImporerService
This is main Commerce Smart Importer Service.

Namespace

Drupal\commerce_smart_importer\Plugin

Code

public function getVariationIdBySku($id) {
  $query = $this->database
    ->query("SELECT variation_id FROM {commerce_product_variation_field_data} WHERE sku='" . $id . "'");
  $sku = $query
    ->fetchAll();
  if (!empty($sku)) {
    return $sku[0]->variation_id;
  }
  else {
    return FALSE;
  }
}