Magento Forum

   
Page 1 of 2
How do I add more than 1001 products to a category in the admin? 
 
HilaryB
Jr. Member
 
Total Posts:  1
Joined:  2010-07-28
 

Is there a cap on the number of products that can be in a category?  I can’t find any documentation that says so.

We are finding that we cannot add more than 1001 products using the admin category management interface (category products tab), any extra products are ignored.

The site uses the Enterprise Edition version 1.9

 
Magento Community Magento Community
Magento Community
Magento Community
 
jainmca4444
Jr. Member
 
Total Posts:  4
Joined:  2010-07-07
 

hello Everyone ,

hi have same issue . i have 5000 product in single category but i can not save more than 1000 product in same category.

Please help me if any body resolve this problem . i am using magento 1.4.1 version

thanks and regard

Ajay Jain

 
Magento Community Magento Community
Magento Community
Magento Community
 
Amasty
Mentor
 
Avatar
Total Posts:  3769
Joined:  2009-11-10
 

Hi,

Feel free to use Mass Product Actions extension to add unlimited number of products to the categories.

 
Magento Community Magento Community
Magento Community
Magento Community
 
symfony XIB
Jr. Member
 
Avatar
Total Posts:  18
Joined:  2008-12-13
The Netherlands
 

A fast fix you could try:

In class Mage_Adminhtml_Catalog_CategoryController , in the saveAction method, replace the following code:

if (isset($data['category_products']) &&
                !
$category->getProductsReadonly()) {
                $products 
= array();
                
parse_str($data['category_products']$products);
                
$category->setPostedProducts($products);
            
}
with
if (isset($data['category_products']) &&
            !
$category->getProductsReadonly()) {
            $products 
= array();
            
$records preg_split('/&/',$data['category_products'],-1,PREG_SPLIT_NO_EMPTY);
            if(
count($records) > 0){
                
foreach($records as $record){
                    $record 
trim($record);
                    if(
preg_match('/([0-9]*)=([0-9]*)/',$record,$matches)){
                        $products[$matches[1]] 
$matches[2];
                    
}
                }
            }
            $category
->setPostedProducts($products);
        
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
symfony XIB
Jr. Member
 
Avatar
Total Posts:  18
Joined:  2008-12-13
The Netherlands
 

Hi,

I’ve just found the explanation:
Since PHP version 5.3.9 , the function parse_str appears to be subject to the php.ini directive “max_input_vars”, which is 1000 by default.
The setting is changeable in php.ini, .htaccess or httpd.conf, but not during runtime.

See:
http://php.net/manual/en/info.configuration.php#ini.max-input-vars

 
Magento Community Magento Community
Magento Community
Magento Community
 
cesium
Jr. Member
 
Total Posts:  5
Joined:  2012-03-16
 
symfony XIB - 20 March 2012 01:23 PM

Hi,

I’ve just found the explanation:
Since PHP version 5.3.9 , the function parse_str appears to be subject to the php.ini directive “max_input_vars”, which is 1000 by default.
The setting is changeable in php.ini, .htaccess or httpd.conf, but not during runtime.

See:
http://php.net/manual/en/info.configuration.php#ini.max-input-vars

Much appreciated this fix was the problem with our Magento Enterprise. Changed the php.ini file, added the variable change as it was not part of the php.ini - rebooted Apache - was able to add more than 1001 products to a category.

Thanks again.

 
Magento Community Magento Community
Magento Community
Magento Community
 
chiefair
Mentor
 
Avatar
Total Posts:  1839
Joined:  2009-06-04
 

So, what rule of thumb do we use on setting max_input_vars?

Is increasing it to a value of say, 5000 sufficient or does it have to be a (MaxNumberOfItemsInCategory + 100) type of setting?

Also mentioned as a source of problems in php applications, the setting max_input_nesting_level. Has anyone encountered this being an issue in Magento?

 
Magento Community Magento Community
Magento Community
Magento Community
 
ircsome
Jr. Member
 
Total Posts:  7
Joined:  2012-01-11
 

Thank you ... you’d think that magento would throw some sort of error when this limit was reached.  I spent a couple of hours trying all sorts of things before realizinf=g there was something magical about 1001 ... so thank you google ‘1001 limit products category magento’ got me here.

Easy fix once you know!

Imagine all those people out there on 999 products in a category having to go through the agony again!

symfony XIB - 20 March 2012 01:23 PM

Hi,

I’ve just found the explanation:
Since PHP version 5.3.9 , the function parse_str appears to be subject to the php.ini directive “max_input_vars”, which is 1000 by default.
The setting is changeable in php.ini, .htaccess or httpd.conf, but not during runtime.

See:
http://php.net/manual/en/info.configuration.php#ini.max-input-vars

 
Magento Community Magento Community
Magento Community
Magento Community
 
Bogislaw
Member
 
Total Posts:  63
Joined:  2009-07-29
 

Having raised max_input_vars to 20,000, three days later we had SSH-Root-Access problems and a server crash. Of course, we’re not sure it was due to this (it’s kinda strange anyway), but since setting it back to 1,000 there are no problems anymore.

http://anothersysadmin.wordpress.com/2012/02/16/php-5-3-max_input_vars-and-big-forms/

 
Magento Community Magento Community
Magento Community
Magento Community
 
mattatai
Jr. Member
 
Total Posts:  3
Joined:  2012-02-15
 

The best solution is not to increase max_input_vars, which is meant after all to mitigate a security vulnerability, but to fix the code.  One fix was previously posted to this thread.  Another is here:

https://gist.github.com/3440260

Hope that helps. I posted a cross-link to this forum in the Magento bug report.

 
Magento Community Magento Community
Magento Community
Magento Community
 
mattatai
Jr. Member
 
Total Posts:  3
Joined:  2012-02-15
 

I heard from Magento Enterprise support that they don’t consider this a bug—details in the bug report (13203).

 
Magento Community Magento Community
Magento Community
Magento Community
 
michael lehmkuhl
Jr. Member
 
Total Posts:  6
Joined:  2009-01-30
 

I’m saddened, but sadly unsurprised by this issue and the support team’s response.

Here’s a configuration-based solution that increases max_input_vars, but only for requests within the Magento admin URL space. So the default value remains in effect for the public-facing forms.

I prefer this method to overwriting Magento core Adminhtml files, since it protects from inadvertent breakage in future Magento upgrades.

<LocationMatch "shop/(index\.php/)?admin/">
    <
IfModule mod_php5.c>
    
php_value max_input_vars 100000
    
</IfModule>
</
LocationMatch>

In this case, Magento is installed in the “shop” directory, and we know we won’t have categories with over 100,000 products.

I hope this is useful for someone else.

Cheers.

 
Magento Community Magento Community
Magento Community
Magento Community
 
chiefair
Mentor
 
Avatar
Total Posts:  1839
Joined:  2009-06-04
 

Thanks Michael. This is a better way of handling reopening a massive security hole by limiting it to the admin instead of systematically recreating the problem for the whole website.

 
Magento Community Magento Community
Magento Community
Magento Community
 
highwaykind
Jr. Member
 
Total Posts:  10
Joined:  2010-08-25
 
michael lehmkuhl - 14 September 2012 02:52 PM

I’m saddened, but sadly unsurprised by this issue and the support team’s response.

Here’s a configuration-based solution that increases max_input_vars, but only for requests within the Magento admin URL space. So the default value remains in effect for the public-facing forms.

I prefer this method to overwriting Magento core Adminhtml files, since it protects from inadvertent breakage in future Magento upgrades.

<LocationMatch "shop/(index\.php/)?admin/">
    <
IfModule mod_php5.c>
    
php_value max_input_vars 100000
    
</IfModule>
</
LocationMatch>

In this case, Magento is installed in the “shop” directory, and we know we won’t have categories with over 100,000 products.

I hope this is useful for someone else.

Cheers.

Where should I copy/paste this code to?
My Associated Products (for Configurable product) are stuck at 999 items (seems like the 1000 limit is hit there).

I tried manually changing php.ini but that doesn’t work and if I put it in htaccess as php_value max_input_vars = 4000 I get a 500 internal server error.

Edit - oops. code in htaccess should be php_value max_input_vars 4000 (without the =, seems to work for now, I can add over 1000 associated products without the error. Still would like to know how to implement the slightly more elegant solution above)

 
Magento Community Magento Community
Magento Community
Magento Community
 
larismedia
Jr. Member
 
Total Posts:  22
Joined:  2011-12-10
 
michael lehmkuhl - 14 September 2012 02:52 PM

I’m saddened, but sadly unsurprised by this issue and the support team’s response.

Here’s a configuration-based solution that increases max_input_vars, but only for requests within the Magento admin URL space. So the default value remains in effect for the public-facing forms.

I prefer this method to overwriting Magento core Adminhtml files, since it protects from inadvertent breakage in future Magento upgrades.

<LocationMatch "shop/(index\.php/)?admin/">
    <
IfModule mod_php5.c>
    
php_value max_input_vars 100000
    
</IfModule>
</
LocationMatch>

In this case, Magento is installed in the “shop” directory, and we know we won’t have categories with over 100,000 products.

I hope this is useful for someone else.

Cheers.

Where do we place the code?

 
Magento Community Magento Community
Magento Community
Magento Community
 
chiefair
Mentor
 
Avatar
Total Posts:  1839
Joined:  2009-06-04
 

In the .htaccess file. It limits the max_input_vars directive from being allowed to anything but the admin backend so Joe Horndog can’t DDOS your website in case a buffer overflow is found.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 1 of 2