Magento Forum

   
Configurable products with lots of simples associated crash the detail page
 
_zen_
Jr. Member
 
Total Posts:  2
Joined:  2010-08-27
 

Hi Guys,

My first ever post here as I can’t find any help on this anywhere else.

Has anyone tryed to use configurable products associated with over 4000 simple products? I’m talking about contact lenses where there are numerous options to configure it (sample http://www.misterspex.co.uk/contact-lenses/air-optix-for-astigm-monthly-disposable_c6390554.html) and this would generate over 4000 possible combinations of simple products.

I’m importing them fine with magmi into 1.8.0.0 install but when I try to access any products with higher than 1000 simples associated, it will crash. i noticed in the mysql logs that it does a lot of requests that end up getting > 100k rows per resultset…

The error:
PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 78 bytes) in /opt/bitnami/apps/magento/htdocs/lib/Zend/Db/Statement/Pdo.php on line 292

I’m concerned that even if I increase the php_value memory_limit to 512M I’ll still end up with a page that takes ages to load due to DB load time.

Any ideas/strategies on using this?

Thanks,
Marius

 
Magento Community Magento Community
Magento Community
Magento Community
 
sammbiz
Jr. Member
 
Total Posts:  16
Joined:  2013-12-15
 

Hi,

This will be help in resolving your concern.

Try this process and resolve your issue.

<?php
ini_set('memory_limit', '1M'); //Raise to 512 MB
ini_set('max_execution_time', '60'); //Raise to 512 MB
class Dijkstra {

var $visited = array();
var $distance = array();
var $previousNode = array();
var $startnode =null;
var $map = array();
var $infiniteDistance = 0;
var $numberOfNodes = 0;
var $bestPath = 0;
var $matrixWidth = 0;

function Dijkstra(&$ourMap, $infiniteDistance) {
$this -> infiniteDistance = $infiniteDistance;
$this -> map = &$ourMap;
$this -> numberOfNodes = count($ourMap);
$this -> bestPath = 0;
}

function findShortestPath($start,$to) {
$this -> startnode = $start;
for ($i=0;$i<$this -> numberOfNodes;$i++) {
if ($i == $this -> startnode) {
$this -> visited[$i] = true;
$this -> distance[$i] = 0;
} else {
$this -> visited[$i] = false;
$this -> distance[$i] = isset($this -> map[$this -> startnode][$i])
? $this -> map[$this -> startnode][$i]
: $this -> infiniteDistance;
}
$this -> previousNode[$i] = $this -> startnode;
}

$maxTries = $this -> numberOfNodes;
$tries = 0;
while (in_array(false,$this -> visited,true) && $tries <= $maxTries) {
$this -> bestPath = $this->findBestPath($this->distance,array_keys($this -> visited,false,true));
if($to !== null && $this -> bestPath === $to) {
break;
}
$this -> updateDistanceAndPrevious($this -> bestPath);
$this -> visited[$this -> bestPath] = true;
$tries++;
}
}

function findBestPath($ourDistance, $ourNodesLeft) {
$bestPath = $this -> infiniteDistance;
$bestNode = 0;
for ($i = 0,$m=count($ourNodesLeft); $i < $m; $i++) {
if($ourDistance[$ourNodesLeft[$i]] < $bestPath) {
$bestPath = $ourDistance[$ourNodesLeft[$i]];
$bestNode = $ourNodesLeft[$i];
}
}
return $bestNode;
}

function updateDistanceAndPrevious($obp) {
for ($i=0;$i<$this -> numberOfNodes;$i++) {
if( (isset($this->map[$obp][$i]))
&& (!($this->map[$obp][$i] == $this->infiniteDistance) || ($this->map[$obp][$i] == 0 ))
&& (($this->distance[$obp] + $this->map[$obp][$i]) < $this -> distance[$i])
)
{
$this -> distance[$i] = $this -> distance[$obp] + $this -> map[$obp][$i];
$this -> previousNode[$i] = $obp;
}
}
}

function printMap(&$map) {
$placeholder = ' %' . strlen($this -> infiniteDistance) .'d';
$foo = '';
for($i=0,$im=count($map);$i<$im;$i++) {
for ($k=0,$m=$im;$k<$m;$k++) {
$foo.= sprintf($placeholder, isset($map[$i][$k]) ? $map[$i][$k] : $this -> infiniteDistance);
}
$foo.= "\n";
}
return $foo;
}

function getResults($to) {
if(trim($to)!="")
{
$ourShortestPath = array();
$foo = '';
for ($i = 0; $i < $this -> numberOfNodes; $i++) {
if($to !== null && $to !== $i) {
continue;
}
$ourShortestPath[$i] = array();
$endNode = null;
$currNode = $i;
$ourShortestPath[$i][] = $i;
while ($endNode === null || $endNode != $this -> startnode) {
$ourShortestPath[$i][] = $this -> previousNode[$currNode];
$endNode = $this -> previousNode[$currNode];
$currNode = $this -> previousNode[$currNode];
}
$ourShortestPath[$i] = array_reverse($ourShortestPath[$i]);
if ($to === null || $to === $i) {
if($this -> distance[$i] >= $this -> infiniteDistance) {
$foo .= sprintf("no route from %d to %d. \n",$this -> startnode,$i);
} else {
$foo .= sprintf(' - Distance = %d (km) <br> - Walking time ~ %d (hrs)<br> - Running time ~ %d (hrs)<br> - Driving time ~ %d (hrs)<br> Nodes [%d] : %s'."\n" ,
$this -> distance[$i], round($this -> distance[$i]/5,2),$this -> distance[$i]/17.2,$this -> distance[$i]/50,
count($ourShortestPath[$i]),
implode('-',$ourShortestPath[$i]));
}
if ($to === $i) {
break;
}
}
}
}
else $foo="";
return $foo;
}
} // end class
?>

For further clarifications, you can contact me.

Regards,
Sanjeev | Website

 
Magento Community Magento Community
Magento Community
Magento Community
 
serpyre
Guru
 
Avatar
Total Posts:  737
Joined:  2013-05-20
 

Of course, it comes down to hosting, standard figure is 0.5-1% of revenue for hosting, however with that many configurables you quite conceivably will need more in to the $100s and likely web clusters to spread the load. We license these setups from a consultancy, companies such as Nexcess will charge you $1,000s/mth. That is the cost of too many simple products, basically you are talking an enterprise class environment to handle that load.

 
Magento Community Magento Community
Magento Community
Magento Community
 
_zen_
Jr. Member
 
Total Posts:  2
Joined:  2010-08-27
 

Thanks serpyre. You’re right about the hosting price as a cost of running the shop. For my specific scenario (client specific budget to be more precise), I had to revert to using simples with custom options as the products’ price won’t change with the selected options.

Cheers,
Marius

 
Magento Community Magento Community
Magento Community
Magento Community
 
Store_Manager
Enthusiast
 
Avatar
Total Posts:  854
Joined:  2012-07-09
 

Hello!

Custom options are much more easier to create and handle, but there is one drawback, in case your products stock is limited and you need to track inventory, you won’t be able to do it with custom options and in case you have sold out one of variations, it will be still visible for client at front-end. So client may buy the products that you actually do not have and delivery will be delayed.

For other users who also have multiple variations of the same products (like you have mentioned 4000 and more), you can use import and create simple goods associated to configurable, but make sure that your server resources are enough and anyway you will have to work on your import file and add all variations there.

There is solution that allows to generate all the combinations of associated to configurable simple products basically in a few clicks -
http://www.mag-manager.com/useful-articles/how-to/how-to-create-all-combinations-of-simple-products-that-belong-to-main-magento-configurable-product-in-2-clicks

It can be performed using extension and it is paid, but in case you need the task to be done once or a few times, you can use 14-days free fully-functional version without any fees -
http://www.magentocommerce.com/magento-connect/store-manager-for-magento-professional-edition-2270.html

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