如何从产品实体(Drupal贸易)获取产品类型?

米兰

我正在查看产品对象。如何获得其类型?

$view = Views::getView('get_all_products');
$view->execute();
foreach ($view->result as $row) { // products
  $product = $row->_entity;
  $product = \Drupal::service('entity.repository')->getTranslationFromContext($product); // Translating it
  $productType = $product-> ????
  ...
Vitaliy Bogomazyuk

我认为这是更好的解决方案:

$product_type = $product->bundle();

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章