1
Drupal 8을 기반으로하는 Drupal commerce 2.x를 사용하고 있습니다. 사용자 정의 모듈에 상점 이름, 전자 메일과 같은 상점 세부 정보에 프로그래밍 방식으로 액세스하려고합니다.Drupal 8 commerce store 설정을 얻는 방법
Drupal 8을 기반으로하는 Drupal commerce 2.x를 사용하고 있습니다. 사용자 정의 모듈에 상점 이름, 전자 메일과 같은 상점 세부 정보에 프로그래밍 방식으로 액세스하려고합니다.Drupal 8 commerce store 설정을 얻는 방법
먼저 당신은 저장소 개체를로드해야합니다
개 이상의 상점이있는 경우$entity_manager = \Drupal::entityManager();
$store = $entity_manager->getStorage('commerce_store')->loadDefault();
$mail = $store->getEmail();
$name = $store->getName();
:
$store_id = 1;
$store = \Drupal\commerce_store\Entity\Store::load($store_id);
은 다음 코드는 당신에게로드 매장, 카트 및 제품 개체에 대한 아이디어를 줄 것이다
$cart_manager = \Drupal::service('commerce_cart.cart_manager');
$cartProvider = \Drupal::service('commerce_cart.cart_provider');
$storeId = $productObj->get('stores')->getValue()[0]['target_id'];
$variationobj = \Drupal::entityTypeManager()
->getStorage('commerce_product_variation')
->load($product_variation_id);
$store = \Drupal::entityTypeManager()
->getStorage('commerce_store')
->load($storeId);
$cart = $cartProvider->getCart('default', $store);