Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to retrieve price information from a Magento product collection
    text
    copied!<p>I am trying to output products from some category on an arbitrary page in a fashion similar to that of list.phtml's grid format.</p> <p>I have the following snippet:</p> <pre><code>$category = Mage::getModel('catalog/category'); $category-&gt;load(17); $_productCollection = $category-&gt;getProductCollection() -&gt;addAttributeToSelect('name'); $_helper = Mage::helper('catalog/output'); </code></pre> <p>That gives me a product collection which I then iterate over with:</p> <pre><code>foreach ($_productCollection as $_product): &lt;!-- This works --&gt; &lt;h2 class="product-name"&gt; &lt;a href="&lt;?php echo $_product-&gt;getProductUrl() ?&gt;" title="&lt;?php echo $this-&gt;stripTags($_product-&gt;getName(), null, true) ?&gt;"&gt; &lt;?php echo $_helper-&gt;productAttribute($_product, $_product-&gt;getName(), 'name') ?&gt; &lt;/a&gt; &lt;/h2&gt; &lt;!-- This does not --&gt; &lt;?php echo $this-&gt;getPriceHtml($_product, true) ?&gt; &lt;!-- This just returns out of stock --&gt; &lt;div class="actions"&gt; &lt;?php if($_product-&gt;isSaleable()): ?&gt; &lt;button type="button" title="&lt;?php echo $this-&gt;__('Add to Cart') ?&gt;" class="button btn-cart" onclick="setLocation('&lt;?php echo $this-&gt;getAddToCartUrl($_product) ?&gt;')"&gt; &lt;span&gt;&lt;span&gt;&lt;?php echo $this-&gt;__('Add to Cart') ?&gt;&lt;/span&gt;&lt;/span&gt; &lt;/button&gt; &lt;?php else: ?&gt; &lt;p class="availability out-of-stock"&gt;&lt;span&gt;&lt;?php echo $this-&gt;__('Out of stock') ?&gt;&lt;/span&gt;&lt;/p&gt; &lt;?php endif; ?&gt; &lt;/div&gt; endforeach; </code></pre> <p>The above code except for the call to get the product collection at the top is just borrowed from list.phtml.</p> <p>Can anyone tell me why the price and is saleable information is not available, hence why the item appears out of stock? Previously when the product name was unavailable, I had to add <code>-&gt;addAttributeToSelect('name')</code>, would I need to add something along those lines?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload