0

I have created a custom table which stores the listId (you can think of it sort of wish list) and product id and created Model and Model resources. What I need is the actual product data based on the product id's who are stored in custom table company_mymodule_shortlist_product . Plus I need to apply the custom filter/sorting on the collection. E.g. I want to filter the product collection base on the create_at filed which is available in my custom table.

Below is the code of Model, Model resource and part of config.xml

config.xml

<models>
    <mymodule>
        <class>Company_MyModule_Model</class>
        <resourceModel>mymodule_resource</resourceModel>
    </mymodule>
    <mymodule_resource>
        <class>Company_MyModule_ModelResource</class>
        <entities>
            <shortlist>
                <table>It stores the list name and its id</table>
            </shortlist>
            <shortlist_product>
                <table>company_mymodule_shortlist_product</table>
            </shortlist_product>
        </entities>
    </mymodule_resource>
</models>

Model:

class Company_MyModule_Model_Shortlist_Product extends Mage_Core_Model_Abstract
{
public function getAllProductsRelatedToShortListId()
    {
        $collection = Mage::getResourceModel('mymodule/shortlist_product_collection');
        foreach($collection as $collections) {
            $collections;
        }
    }
}

Resource Model:

class Company_MyModule_Model_Resource_Shortlist_Product_Collection extends Mage_Catalog_Model_Resource_Product_Collection
{

}

Edit:

After hours of digging I found that I will need to extend the Resource collection of shortlist_product with Mage_Catalog_Model_Resource_Product_Collection which I have done successfully. But now I do not know how to add the custom table data into the product collection so that I get all the required products data. Infact a proper Magento product collection with all sorting, filtering etc.

0
0

You can use join to join your custom table with product collection based on product_id. Refer this link http://magentotutorial.in/join-custom-table-to-product-collection-in-magento/

Not the answer you're looking for? Browse other questions tagged or ask your own question.