Version Notes
fix performance issue on catalog
Download this release
Release Info
Developer | George Babarus |
Extension | bb_eav |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
app/code/community/Bb/Eav/Model/Entity/Attribute/Source/Table.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* George Babarus extension for Magento
|
4 |
+
*
|
5 |
+
* Long description of this file (if any...)
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://opensource.org/licenses/osl-3.0.php
|
13 |
+
*
|
14 |
+
* DISCLAIMER
|
15 |
+
*
|
16 |
+
* Do not edit or add to this file if you wish to upgrade
|
17 |
+
* the Bb Eav module to newer versions in the future.
|
18 |
+
* If you wish to customize the Bb Eav module for your needs
|
19 |
+
* please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Bb
|
22 |
+
* @package Bb_Eav
|
23 |
+
* @copyright Copyright (C) 2014 http://www.babarus.ro
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Fix a performance issue for Magento community and enterprise related to
|
29 |
+
* attributes get option text by option id
|
30 |
+
*
|
31 |
+
* Issue was fixed by replacing the way to find option label in getOptionText method
|
32 |
+
*
|
33 |
+
* @category Bb
|
34 |
+
* @package Bb_Eav
|
35 |
+
* @subpackage Model
|
36 |
+
* @author George Babarus <george.babarus@gmail.com>
|
37 |
+
*/
|
38 |
+
|
39 |
+
class Bb_Eav_Model_Entity_Attribute_Source_Table extends Mage_Eav_Model_Entity_Attribute_Source_Table
|
40 |
+
{
|
41 |
+
|
42 |
+
|
43 |
+
/**
|
44 |
+
* return an array of selected option label and value of attribute for product
|
45 |
+
*
|
46 |
+
* @param $optionsIds
|
47 |
+
* @return mixed
|
48 |
+
*/
|
49 |
+
public function getOptionTextByOptionId($optionsIds){
|
50 |
+
if(!is_array($optionsIds)){
|
51 |
+
return array();
|
52 |
+
}
|
53 |
+
|
54 |
+
$collection = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
55 |
+
->setPositionOrder('asc')
|
56 |
+
->setAttributeFilter($this->getAttribute()->getId())
|
57 |
+
->setStoreFilter($this->getAttribute()->getStoreId());
|
58 |
+
|
59 |
+
|
60 |
+
$collection->getSelect()
|
61 |
+
->where('main_table.option_id IN (?)',$optionsIds);
|
62 |
+
|
63 |
+
$collection->load();
|
64 |
+
|
65 |
+
return $collection->toOptionArray();
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Get a text for option value
|
70 |
+
*
|
71 |
+
* @param string|integer $value
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
public function getOptionText($value)
|
75 |
+
{
|
76 |
+
$isMultiple = false;
|
77 |
+
if (strpos($value, ',')) {
|
78 |
+
$isMultiple = true;
|
79 |
+
$value = explode(',', $value);
|
80 |
+
} else {
|
81 |
+
if (!empty($value)) {
|
82 |
+
$value = array($value);
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
$options = $this->getOptionTextByOptionId($value);
|
87 |
+
|
88 |
+
if ($isMultiple) {
|
89 |
+
$values = array();
|
90 |
+
foreach ($options as $item) {
|
91 |
+
if (in_array($item['value'], $value)) {
|
92 |
+
$values[] = $item['label'];
|
93 |
+
}
|
94 |
+
}
|
95 |
+
return $values;
|
96 |
+
}
|
97 |
+
|
98 |
+
foreach ($options as $item) {
|
99 |
+
if (in_array($item['value'], $value)) {
|
100 |
+
return $item['label'];
|
101 |
+
}
|
102 |
+
}
|
103 |
+
return false;
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
|
108 |
+
}
|
app/code/community/Bb/Eav/etc/config.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Bb_Eav>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Bb_Eav>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<bb_eav>
|
11 |
+
<class>Bb_Eav_Model</class>
|
12 |
+
</bb_eav>
|
13 |
+
<eav>
|
14 |
+
<rewrite>
|
15 |
+
<entity_attribute_source_table>Bb_Eav_Model_Entity_Attribute_Source_Table</entity_attribute_source_table>
|
16 |
+
</rewrite>
|
17 |
+
</eav>
|
18 |
+
</models>
|
19 |
+
</global>
|
20 |
+
|
21 |
+
</config>
|
app/etc/modules/Bb_Eav.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<config>
|
2 |
+
<modules>
|
3 |
+
<Bb_Eav>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Eav />
|
9 |
+
</depends>
|
10 |
+
</Bb_Eav>
|
11 |
+
</modules>
|
12 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>bb_eav</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Performance fix for EAV module</summary>
|
10 |
+
<description>This module is a performance fix for all community and enterprise versions before Community 1.9 edition. Since I worked for a store having a very complex products (with a large numbers of attributes and large scale of values), I discovered that Magento has a performance bottleneck on product listing page and product page. </description>
|
11 |
+
<notes>fix performance issue on catalog</notes>
|
12 |
+
<authors><author><name>George Babarus</name><user>MAG000308246</user><email>george.babarus@gmail.com</email></author></authors>
|
13 |
+
<date>2014-11-17</date>
|
14 |
+
<time>12:30:29</time>
|
15 |
+
<contents><target name="mage"><dir name="app"><dir name="code"><dir name="community"><dir name="Bb"><dir name="Eav"><dir name="Model"><dir name="Entity"><dir name="Attribute"><dir name="Source"><file name="Table.php" hash="820dc510f9ce8b79201aa316e603751a"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="e33df9c1035f070630c9226644d3db14"/></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Bb_Eav.xml" hash="5bde51bb75704932a26bc747184cdfc3"/></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.3.1</min><max>5.6.0</max></php></required></dependencies>
|
18 |
+
</package>
|