Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Adding products statuses
 
beowax
Sr. Member
 
Total Posts:  94
Joined:  2007-12-17
Lille, France
 

Hello community,

I’m trying to add few status to products (like ‘Have to complete meta description’ before they are publish) in Magento. Here is what i have done :

1 : I have created a /app/locale/XyzCorp/Catalog/Model/Product/Status.php file whiche contains :

class XyzCorp_Catalog_Model_Product_Status extends Mage_Catalog_Model_Product_Status {
        
const STATUS_A_TRAVAVAILLER      4;
        const 
STATUS_A_PUBLIER           5;
    
    
}

2 : I created a /app/locale/XzyCorp/Catalog/Model/Entity/Product/Status/Collection.php file, containing :

<?php
class XyzCorp_Catalog_Model_Entity_Product_Status_Collection extends Mage_Catalog_Model_Entity_Product_Status_Collection {
    
public function toOptionArray()
    
{
        
return array(
            array(
'value' => XyzCorp_Catalog_Model_Product::STATUS_ENABLED'label' => Mage::helper('catalog')->__('Enabled') ),
            array(
'value' => XyzCorp_Catalog_Model_Product::STATUS_DISABLED'label' => Mage::helper('catalog')->__('Disabled') ),
            array(
'value' => XyzCorp_Catalog_Model_Product::STATUS_A_TRAVAILLER'label' => Mage::helper('catalog')->__('A travailler') ),
            array(
'value' => XyzCorp_Catalog_Model_Product::STATUS_A_PUBLIER'label' => Mage::helper('catalog')->__('A publier') ),
        );
        
//return $this->_toOptionArray('status_id', 'status_code');
    
}

    
public function toOptionHash()
    
{
        
return array(
            
XyzCorp_Catalog_Model_Product::STATUS_ENABLED => Mage::helper('catalog')->__('Enabled'),
            
XyzCorp_Catalog_Model_Product::STATUS_DISABLED=> Mage::helper('catalog')->__('Disabled'),
            
XyzCorp_Catalog_Model_Product::STATUS_A_TRAVAILLER => Mage::helper('catalog')->__('A travailler'),
            
XyzCorp_Catalog_Model_Product::STATUS_A_PUBLIER=> Mage::helper('catalog')->__('A publier'),
            
        );
        
//return $this->_toOptionHash('status_id', 'status_code');
    
}
    }
?>

3 : I edited the /local.xml file. Now it contains :

<?xml version="1.0"?>
<!--
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @category   Mage
 * @package    Mage_Core
 * @copyright  Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
-->
<
config>
    <global>
        <
install>
            <
date><![CDATA[Wed30 Jan 2008 11:02:10 +0000]]></date>
        </
install>
        <
crypt>
            <
key><![CDATA[97e77bab9bba40e5d73b0b8aa90b0dcf]]></key>
        </
crypt>
        <
resources>
            <
default_setup>
                <
connection>
                    <
host><![CDATA[localhost]]></host>
                    <
username><![CDATA[root]]></username>
                    <
password><![CDATA[password]]></password>
                    <
dbname><![CDATA[magento]]></dbname>
                    <
active>1</active>
                </
connection>
            </
default_setup>
            <
default_write>
                <
connection>
                    <
host><![CDATA[localhost]]></host>
                    <
username><![CDATA[root]]></username>
                    <
password><![CDATA[password]]></password>
                    <
dbname><![CDATA[magento]]></dbname>
                    <
active>1</active>
                </
connection>
            </
default_write>
         </
resources>
        <
modules>
            <
XyzCorp_Catalog>
                <
active>true</active>
                <
codePool>local</codePool>
            </
XyzCorp_Catalog>
        </
modules>
        <
product>
            <
model>
                <
catalog>
                    <
rewrite>
                        <
status>XyzCorp_Catalog_Model_Product_Status</status>
                    </
rewrite>
                </
catalog>
            </
model>
        </
product>
        <
status>
            <
product>
                <
entity>
                    <
model>
                        <
catalog>
                            <
rewrite>
                                <
collection>XyzCorp_Catalog_Model_Entity_Product_Status_Collection</collection>
                            </
rewrite>
                        </
catalog>
                    </
model>
                </
entity>
            </
product>
        </
status>
     </global>
</
config>

In admin as in frontend, i can’t see these statuses…

Can somebody (Moshe, other Magento developper or somebody of the community) tell me what i have miss ?

Thanks,
Antoine

 
Magento Community Magento Community
Magento Community
Magento Community
 
beowax
Sr. Member
 
Total Posts:  94
Joined:  2007-12-17
Lille, France
 

As i forgot to say, i also inserted the 4 and 5 records in catalog_product_status

 
Magento Community Magento Community
Magento Community
Magento Community
 
beowax
Sr. Member
 
Total Posts:  94
Joined:  2007-12-17
Lille, France
 

I think i went on the wrong way again with the above stuff.

I followed this tutorial : http://www.magentocommerce.com/wiki/how-to/customize_part_of_configuration in order to override the Mage_Catalog_Model_Entity_Product_Status_Collection class.

The problem is that the catalog/product_status_collection is grabbed by the method “getRessourceModel”, and not “getModel”, so my changes can’t be seen. I’m searched all day doing this, i’m going crazy with that stuff.

Does somebody knows how to override this king of class ?

Regards,
Antoine

 
Magento Community Magento Community
Magento Community
Magento Community
 
SeL_
Magento Team
 
Avatar
Total Posts:  1140
Joined:  2007-10-10
Paris, France
 

Hi,

Try the following.
Create a file
app/code/local/XzyCorp/Catalog/etc/config.xml:
with this in it:

<?xml version="1.0"?>
<config>
  <global>
    <
models>
      <
catalog>
        <
rewrite>
          <
entity_product_status_collection>XyzCorp_Catalog_Model_Entity_Product_Status_Collection</entity_product_status_collection>
          <
product_status>XyzCorp_Catalog_Model_Product_Status</product_status>
        </
rewrite>
      </
catalog>
Tell us if this works.
 
Magento Community Magento Community
Magento Community
Magento Community
 
beowax
Sr. Member
 
Total Posts:  94
Joined:  2007-12-17
Lille, France
 

Hi SeL,

As i followed the tutorial, i already created the file.

As i said above, the problem was that statuses were called with the getRessourceModel method, not the getModel one. So i override few classes and blocks to call the method the good way. Now my statuses are in the product edition page. I’m actually trying to makr them appear in the product grid and the search field.

Regards,
Antoine

 
Magento Community Magento Community
Magento Community
Magento Community
 
beowax
Sr. Member
 
Total Posts:  94
Joined:  2007-12-17
Lille, France
 

By the way, if I change the status field of one of the product to Disabled or Out-of-Stock then the variant option is still available on the product page and I am able to add the product to my shopping cart.

I noticed this in the previous version too, is it a problem with my install or do you observe it too ?

Regards,
Antoine

 
Magento Community Magento Community
Magento Community
Magento Community
 
beowax
Sr. Member
 
Total Posts:  94
Joined:  2007-12-17
Lille, France
 

As i said above, i finally managed ti create status and see them in the product’s editing page.

Now, i’m searching to show theses new statuses in the product grid and mass action form, but i have a strange problem.

I created a class called XyzCorp_Adminhtml_Block_Catalog_Product_Grid which exends Mage_Adminhtml_Block_Catalog_Product_Grid. I also declare a new _prepareColumns method, which contains my new code.

When i go to backend, i can’t see my new status, nor in the massaction form, nor on the product which status changed.

The problem is that the _prepareColumns comes from Mage_Adminhtml_Block_Catalog_Product_Grid, not from XyzCorp_Adminhtml_Block_Catalog_Product_Grid ! When i suppress the _prepareColumns from the Mage_Adminhtml_Block_Catalog_Product_Grid class, my method is called and i get the expected result.

How can i tell magento to override the method ?

Regards,
Antoine

 
Magento Community Magento Community
Magento Community
Magento Community
 
SeL_
Magento Team
 
Avatar
Total Posts:  1140
Joined:  2007-10-10
Paris, France
 
averhelst - 13 February 2008 01:03 AM

By the way, if I change the status field of one of the product to Disabled or Out-of-Stock then the variant option is still available on the product page and I am able to add the product to my shopping cart.

I just tried this. I changed one product status to ‘Out of stock’. When i try to add the product with the option, i get the following message: ‘This product is currently out of stock.’
And it’s still possible to add other options (in stock) to the cart.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top