Answers.Body: <p>Haha. I figured it out. Leaving the answer here in case anyone else runs into the same problem:</p>
  
  <pre><code>$product = Entry::find()-&gt;section('products')-&gt;relatedTo([
      'element' =&gt; $component,
      'field' =&gt; 'productComponents'
  ])-&gt;one();
  </code></pre>
  
  <p>You can pass an object/array to the relatedTo() method as described here:</p>
  
  <p><a href="https://docs.craftcms.com/v3/relations.html#the-relatedto-parameter" rel="nofollow noreferrer">Relations | Craft 3 Documentation</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-26T17:59:56.117Z
Answers.LastActivityDate: 2019-02-26T17:59:56.117Z
Answers.UserDisplayName: Tony DeStefano
Body: <p>I have a Product entry type that contains a field for Components (which are also products) and a field for Related Products (again, also Products). I want to be able to find a parent product from a Component, but using a relatedTo() gives me all the Products on which it is a Related Product as well.</p>
  
  <p>Is there a way to specify which field you want to use with the relatedTo() method?</p>
  
  <pre><code>$product = Entry::find()-&gt;section('products')-&gt;relatedTo($component)-&gt;one();
  </code></pre>
  
  <p>Expected result = The parent product.</p>
  
  <p>Actual result = A random product on which the component is a related item.</p>
  
  <p>Of course, this was all working great until I just recently added the Related Products field.</p>
  
Tags: <craft3><entry><elementquery>
Title: relatedTo() only on one field?
ThreadText: # relatedTo() only on one field?
  
  (Asked by: username_0 on 2019-02-26)
  
  I have a Product entry type that contains a field for Components (which are also products) and a field for Related Products (again, also Products). I want to be able to find a parent product from a Component, but using a relatedTo() gives me all the Products on which it is a Related Product as well.
  
  Is there a way to specify which field you want to use with the relatedTo() method?
  
  ```
  $product = Entry::find()->section('products')->relatedTo($component)->one();
  
  ```
  
  Expected result = The parent product.
  
  Actual result = A random product on which the component is a related item.
  
  Of course, this was all working great until I just recently added the Related Products field.
  
  **Tags:** craft3, entry, elementquery
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-02-26. Score: 3 | Accepted answer
  
  Haha. I figured it out. Leaving the answer here in case anyone else runs into the same problem:
  
  ```
  $product = Entry::find()->section('products')->relatedTo([
      'element' => $component,
      'field' => 'productComponents'
  ])->one();
  
  ```
  
  You can pass an object/array to the relatedTo() method as described here:
  
  [Relations | Craft 3 Documentation](https://docs.craftcms.com/v3/relations.html#the-relatedto-parameter)
  
  
  ---
  
  