<p>I have the following</p>

<pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria('Commerce_Product');
$criteria-&gt;search = 'unquieId:' . $result['id'];
$criteria-&gt;status = null;
$product = $criteria-&gt;find();
</code></pre>

<p>The unique result returns a product if it's there and ideally empty if it's not. The odd behavior I'm seeing is if the product is marked disabled in Craft Commerce then the product is returned empty. I thought the status null may help but I don't think they equate. Any thoughts?</p>

CC BY-SA 3.0
2016-05-05T20:30:43.433Z
I'm not able to reproduce this. If a product is disabled, then using `$criteria->status = null;` will find it and removing that line won't find it.
Brad Bell
CC BY-SA 3.0
2016-07-21T15:30:08.123Z
This also works for me. Can you check the value of `$result['id']` and then check to see whether manually adding the results id works? So something like `$criteria->search = 'unquieId:12';`
Luke Pearce
<plugin-development><plugin-craftcommerce>
Commerce - Get Model via Custom Field
# Commerce - Get Model via Custom Field

(Asked by: username_0 on 2016-05-05)

I have the following
$criteria = craft()->elements->getCriteria('Commerce_Product');
$criteria->search = 'unquieId:' . $result['id'];
$criteria->status = null;
$product = $criteria->find();

The unique result returns a product if it's there and ideally empty if it's not. The odd behavior I'm seeing is if the product is marked disabled in Craft Commerce then the product is returned empty. I thought the status null may help but I don't think they equate. Any thoughts?

**Tags:** plugin-development, plugin-craftcommerce
> **Comments:**
> **username_1**: I'm not able to reproduce this. If a product is disabled, then using `$criteria->status = null;` will find it and removing that line won't find it.  
> **username_2**: This also works for me. Can you check the value of `$result['id']` and then check to see whether manually adding the results id works? So something like `$criteria->search = 'unquieId:12';`  

---

## 0 answers

