title: Magento Get Product Attribute Text in Stock.php
body: <p>I've been trying to adjust the amount stock reduced by a sale, depending on a product's attribute, I've tried the following methods, but seem to be getting nowhere.</p>
  
  <p>Magento Version: 1.8.0.0</p>
  
  <p>File: /app/code/core/Mage/CatalogInventory/Model/Resource/Stock.php</p>
  
  <p>Around line 158 after: foreach ($productQtys as $productId => $qty)</p>
  
  <p>I have added the following code:</p>
  
  <pre><code>$CheckLength = Mage::getModel('catalog/product')-&gt;load($_item['product_id'])-&gt;getData('length');
  if ( $CheckLength == 'Per Half Metre' )
  {
      $qty = $qty / 2;
  }
  </code></pre>
  
  <p>and also tried this:</p>
  
  <pre><code>$myproduct = Mage::getModel('catalog/product');
  
  if ($myproduct-&gt;getAttributeText('length')=='per Half Metre')
  {
      $qty = $qty / 2;
  }
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>$storeId = Mage::app()-&gt;getStore()-&gt;getId(); // return current store id
  $CheckLength = Mage::getResourceModel('catalog/product')-&gt;getAttributeRawValue($productId, 'length', $storeId);
  
  if ( $CheckLength == 'Per Half Metre' )
  {
      $qty = $qty / 2;
  }
  </code></pre>
  
  <p>None of the above seem to work. Without the check, the qty divides by 2 quite nicely as I need, but I only need it to do it if the Product Attribute is "Per Half Metre".</p>
  
  <p>PS: This attribute is in a drop down with 2 other options.</p>
  
  <p>Hope someone can help! Thanks in Advance.</p>