Posted by: james | September 14, 2009

new

yif you use entity..then you can get collection of prodcuts, customers and orders and all that.. and you can apply

function on that.. to see all the function go to app/code/core/Mage/Eav/Model/Entity/collection/Abstract.php

app/etc/modules/form_filteroutstock.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<config>
<modules>
<form_FilterOutStock>
<active>true</active>
<codePool>local</codePool>
</form_FilterOutStock>
</modules>
</config>
app/code/local/form/filteroutstock/etc/config.xml

<?xml version=”1.0″ encoding=”UTF-8″?>
<config>
<modules>
<form_FilterOutStock>
<version>0.1.0</version>
</form_FilterOutStock>
</modules>

<global>
<models>
<filteroutstock>
<class>form_FilterOutStock_Model</class>
</filteroutstock>
</models>
<resources>
<filteroutstock_setup>
<setup>
<module>form_FilterOutStock</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</filteroutstock_setup>
<filteroutstock_write>
<connection>
<use>core_write</use>
</connection>
</filteroutstock_write>
<filteroutstock_read>
<connection>
<use>core_read</use>
</connection>
</filteroutstock_read>
</resources>
<blocks>
<filteroutstock>
<class>form_FilterOutStock_Block</class>
</filteroutstock>
</blocks>

<helpers>
<filteroutstock>
<class>form_FilterOutStock_Helper</class>
</filteroutstock>
</helpers>
</global>

<frontend>
<events>
<catalog_product_collection_load_before>
<observers>
<filteroutstock>
<type>singleton</type>
<class>filteroutstock/observer</class>
<method>processBeforeLoadEvent</method>
</filteroutstock>
</observers>
</catalog_product_collection_load_before>
</events>
<routers>
<filteroutstock>
<use>standard</use>
<args>
<module>form_FilterOutStock</module>
<frontName>filteroutstock</frontName>
</args>
</filteroutstock>
</routers>
</frontend>
</config>

app/code/local/form/fileroutstock/model/Observer.php
<?php
class form_FilterOutStock_Model_Observer extends Mage_Core_Model_Abstract
{
public function processBeforeLoadEvent(Varien_Event_Observer $observer)
{
$collection = $observer->getEvent()->getCollection();
$collection->joinField(
‘stock_status’,
‘cataloginventory/stock_status’,
‘stock_status’,
‘product_id=entity_id’, array(
‘stock_status’ =>

Mage_CatalogInventory_Model_Stock_Status::STATUS_IN_STOCK,
‘website_id’ => Mage::app()->getWebsite()->getWebsiteId(),
)
);
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: