Answers.Body: <p>I believe you're looking for something like:</p>
  <pre><code>$purchasable-&gt;product-&gt;yourEntriesFieldHandle-&gt;one()-&gt;title
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-24T21:29:33.160Z
Answers.Text: Yes. Brilliant. Thank you. I'd love to know 'how' you know that? I've not been able to find this indicated in the docs, and of I take a look at the $purchasable object I don't see 'product' as an item. Cheers though!
Answers.UserDisplayName: Mere Development
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-27T08:55:00.920Z
Answers.Text: I knew this because $purchasable is an instance of a Variant, and all variants have a parent product. If you dump out $purchasable (`Craft::dd($purchasable);`) you can see that it's a Variant and has a nested object representing the Product. Here's the relevant part of the docs: https://docs.craftcms.com/commerce/api/v3/craft-commerce-elements-variant.html#product
Answers.UserDisplayName: James Smith
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-24T20:18:16.710Z
Answers.LastActivityDate: 2020-07-24T20:18:16.710Z
Answers.UserDisplayName: James Smith
Body: <p>I've added an Entries field called <code>linkedCourseEntry</code> to a Product (Product Type &gt; Product Fields tab). In the Product itself I've assigned an entry.</p>
  <p>I need to access <code>linkedCourseEntry</code> from one or more Events, but can’t work out how to do so.</p>
  <p>For example when <code>EVENT_POPULATE_LINE_ITEM</code> is used:</p>
  <pre><code>Event::on(
      LineItems::class,
      LineItems::EVENT_POPULATE_LINE_ITEM,
      function(LineItemEvent $event) {
  
          $lineItem = $event-&gt;lineItem;
          $purchasable = $lineItem-&gt;getPurchasable();
  
          // Somehow access the 'linkedCourseEntry' data here... help! 
      }
  );
  </code></pre>
  <p>Can anyone point me in the right direction please?</p>
  
Tags: <craft3><events><modules><plugin-craftcommerce3>
Title: Accessing Commerce ‘Product Fields’ in events hooks
ThreadText: # Accessing Commerce ‘Product Fields’ in events hooks
  
  (Asked by: username_0 on 2020-07-24)
  
  I've added an Entries field called `linkedCourseEntry` to a Product (Product Type > Product Fields tab). In the Product itself I've assigned an entry.
  
  I need to access `linkedCourseEntry` from one or more Events, but can’t work out how to do so.
  
  For example when `EVENT_POPULATE_LINE_ITEM` is used:
  
  ```
  Event::on(
      LineItems::class,
      LineItems::EVENT_POPULATE_LINE_ITEM,
      function(LineItemEvent $event) {
  
          $lineItem = $event->lineItem;
          $purchasable = $lineItem->getPurchasable();
  
          // Somehow access the 'linkedCourseEntry' data here... help! 
      }
  );
  
  ```
  
  Can anyone point me in the right direction please?
  
  **Tags:** craft3, events, modules, plugin-craftcommerce3
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-07-24. Score: 2 | Accepted answer
  
  I believe you're looking for something like:
  
  ```
  $purchasable->product->yourEntriesFieldHandle->one()->title
  
  ```
  
  > **Comments:**
  > **username_0**: Yes. Brilliant. Thank you. I'd love to know 'how' you know that? I've not been able to find this indicated in the docs, and of I take a look at the $purchasable object I don't see 'product' as an item. Cheers though!  
  > **username_1**: I knew this because $purchasable is an instance of a Variant, and all variants have a parent product. If you dump out $purchasable (`Craft::dd($purchasable);`) you can see that it's a Variant and has a nested object representing the Product. Here's the relevant part of the docs: https://docs.craftcms.com/commerce/api/v3/craft-commerce-elements-variant.html#product  
  
  ---
  
  