title: Magento isSalable returning nothing
body: <p>I ran into a problem somehow where a product that is in stock and has a quantity of over 400000 is saying it is not salable. Or rather isSalable is not returning a value.</p>
  
  <p>I pulled up the function to take a look and I noticed something odd.</p>
  
  <p>Here is the function:</p>
  
  <pre><code>public function isSalable(){
      Mage::dispatchEvent('catalog_product_is_salable_before', array(
          'product'   =&gt; $this
      ));
      $salable = $this-&gt;isAvailable();
      $object = new Varien_Object(array(
          'product'    =&gt; $this,
          'is_salable' =&gt; $salable
      ));
      Mage::dispatchEvent('catalog_product_is_salable_after', array(
          'product'   =&gt; $this,
          'salable'   =&gt; $object
      ));
      // echo "variable: ".$salable."&lt;br /&gt;object: ".$object-&gt;getIsSalable();
  
      return $object-&gt;getIsSalable();
  }
  </code></pre>
  
  <p>The commented echo was to see the value before it was put into the object and the value retrieved from the object. On the problem product I get:</p>
  
  <pre><code>variable: 1
  object: 
  </code></pre>
  
  <p>On other products they both come back as 1.</p>
  
  <p>Does anyone know what would cause this to happen?</p>
  
  <p><strong>---EDIT---</strong></p>
  
  <p>Sorry, the function returns <code>$object-&gt;getIsSalable()</code>, not <code>$salable</code>.</p>
  
  <p>This is on <strong>Magento Enterprise 1.12</strong></p>
  
  <p>I realize now that the object call is returning false. The effects of posting this at the end of the day.</p>
  
  <p>I moved the echo to before the event dispatch and both came back as 1 so i looked into the event and tracked down where it is setting it to false.</p>
  
  <p>I tracked it to this function in Enterprise/CatalogEvent:</p>
  
  <pre><code>public function applyIsSalableToProduct(Varien_Event_Observer $observer){
      $event = $observer-&gt;getEvent()-&gt;getProduct()-&gt;getEvent();
      echo "&lt;br /&gt;".$event-&gt;getStatus()."&lt;br /&gt;";
      if ($event &amp;&amp; in_array($event-&gt;getStatus(), array(
                  Enterprise_CatalogEvent_Model_Event::STATUS_CLOSED,
                  Enterprise_CatalogEvent_Model_Event::STATUS_UPCOMING
      ))) {
          $observer-&gt;getEvent()-&gt;getSalable()-&gt;setIsSalable(false);
      }
      return $this;
  }
  </code></pre>
  
  <p>If I echo <code>$event-&gt;getStatus()</code> outside the if, the problem product gives a status of closed, and other products throw an error because $event doesn't exist.</p>
  
  <p>What is causing the difference?</p>
  
  <p><strong>---EDIT 2---</strong></p>
  
  <p>I've found that the closed is coming from the product event.</p>
  
  <pre><code>$event = $observer-&gt;getEvent()-&gt;getProduct()-&gt;getEvent();
  </code></pre>
  
  <p>I went back to <code>isSalable()</code> and added <code>print_r($this-&gt;getEvent()-&gt;getData());</code> after the object creation and got this:</p>
  
  <pre><code>Array([event_id] =&gt; 3 [category_id] =&gt; 12 [date_start] =&gt; 2012-11-28 09:54:00 [date_end] =&gt; 2012-11-29 09:54:00 [display_state] =&gt; [sort_order] =&gt; [status] =&gt; closed)
  </code></pre>
  
  <p>Again, normal products come back with an error because there is no event on the product.</p>
  
  <p>Where does this event come from?</p>
  
  <p>I'll keep updating as I make progress.</p>