Hiding “Out of Stock” items in Layered Navigation

July 14th, 2009

Updated 9/28/09

See the latest post in this series: Yet Another “Hiding Out-Of-Stock Products” Update, for an update that fixes advanced search, tags, up-sells, cross-sells, etc..

Updated 7/23/09

Updated once again to add support for filtering search results. (Added CatalogSearch/Model/Layer.php, moved Model/Layer.php to Catalog/Model/Layer.php, updated config.xml)

My previous post about “Hiding Out of Stock Items in Magento” had one pretty major downfall, in that it did not handle the product counts in the layered navigation. In response to a forum post regarding this I looked into fixing my original solution and have come up with a more concise and complete approach which I present now as a replacement to my original InStockOnly module.

Read more…

Magento, Programming

Adding Minimal Price To Any Product Collection in Magento

June 4th, 2009

There are many “Bestseller“, “Most Viewed”, and other front-page modules available for Magento. Those that use the Reports module to maintain good performance have the slight drawback that they do not inherit the catalog/product_collection resource model and it’s handy addMinimalPrices() function. This function adds the fields necessary for the getPriceHtml($product, TRUE) function to work, which prints out the “As low as” text for products that have tiered pricing. This is a must-have feature if you use tiered pricing, so here is how you can make getPriceHTML($product, TRUE) work with any collection of products:

$productIds = array_keys($_products->getItems());
$minimalPriceModel = Mage::getResourceModel('catalogindex/price');
$minimalPriceModel->setStoreId(Mage::app()->getStore()->getId());
$minimalPriceModel->setCustomerGroupId(
  Mage::getSingleton('customer/session')->getCustomerGroupId());
$minimalPrices = $minimalPriceModel->getMinimalPrices($productIds);
foreach ($minimalPrices as $row) {
  $item = $_products->getItemById($row['entity_id']);
  if ($item) {
    $item->setData('minimal_price', $row['value']);
    $item->setData('minimal_tax_class_id', $row['tax_class_id']);
  }
}

There you have it!

Magento ,

Hiding “Out of Stock” Items in Magento

June 2nd, 2009

Updated 7/14/09

This module has been replaced with one that correctly updates the layered navigation counts. See the new version here.

Updated 7/3/09

The in-stock-only module now works properly when multiple websites are in use.

Updated 6/26/09

The in-stock-only module now works with configurable products.

 

Magento has several criteria for determining if an item should be visible in the store, but one of these is not whether or not the item is in stock. Magento can manage your stock and will set your stock status to “Out of Stock” for you, but what if you want these out of stock items to be hidden from the store.. automatically? Also, in my case I do not want to “disable” the item because the inventory management system will then ignore it. Turns out this was much more difficult to figure out than I expected it to be but the end solution was quite simple.

Read more…

Magento, Programming ,

Implementing Zend Framework’s “Conventional Modular” Directory Structure in Kohana

April 19th, 2009

There is a little conflict in terms here because “modules” are not the same to Kohana as they are to Zend Framework and Yii Framework, which both have support for modular directory structures. In Kohana, modules are like plugins to the framework which can change or add functionality to the core to be made use of in the application. The “Conventional Modular” Directory Structure in Zend Framework is a configuration option, and modules are more like sub-applications; essentially just a neat way to organize various components of an application.

Read more…

Programming , ,

Event Delegation for Prototype

March 23rd, 2009

Today I’d like to present my own rendition of an Event Delegator class based on Prototype. Event Delegation can be used to improve performance and code simplicity by observing one parent element and triggering events on the children when applicable rather than observing each child element individually.

Read more…

Programming ,

DAMit Version 2

November 18th, 2008

While working at Seelab at The University of Tennessee in 2006 one of my first tasks was to rename every function in what is now the Visualization CookBook, but was previously another name. We developed a simple Document for API Modification and called it the DAM document. I then wrote a Perl script to apply the DAM document to user’s source code to ease the pains of a major API modification and we named it “DAMit”. Yes, we too thought it was funny.

Read more…

Programming ,

Ajax.DoubleCombo update

November 11th, 2008

Due to a recent request about my Ajax.DoubleCombo class, I have updated it to support automatic updates trickling down when the server returns a “selected” value or the default value is non-void. In the process, I added some Prototype 1.6 custom events, namely doubleCombo:update and doubleCombo:clearSlaves which in turn added support for what I will call “branching”. That is, support for multiple slave selects at each level. I don’t know if anyone has a use for this but it is now supported…

Here is the page with the code, docs and demo: Ajax.DoubleCombo

Programming ,

Setup an SVN repo on a school server

September 17th, 2008

I like Subversion, and think it is useful for the various group projects I’ve done at the University of Tennessee in the EECS department. I figured some other students on a unix-based network with limited privileges might also, and could use a quick tutorial for setting up Subversion on one member’s user account in such a way that is secure, doesn’t require labstaff adding any groups, and is still easy for fellow classmates to access while maintaining user identity in the Subversion logs. The only downside is one user has to be the host, so everyone run quota and the sucker with the most free space gets to host the repository… :(

Read more…

Programming ,

My humble website is born…

September 11th, 2008

Ok, so what kind of web developer doesn’t have a website? Me, but not anymore. :)

Uncategorized