Я использую Drupal commerce 2.x, основанный на Drupal 8. Я хочу получить доступ к деталям магазина, например, имя магазина, программно программировать в моем настраиваемом модуле.Как получить настройку магазина торговли Drupal 8
1
A
ответ
2
Прежде всего, необходимо загрузить в магазин объект:
$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);
0
После кода даст вам представление о магазине нагрузки, тележки и объект продукта
$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);