Configurable_Product_Whith_Child_Image_Gallery - Version 0.0.1

Version Notes

Nothing.

Download this release

Release Info

Developer Brunet
Extension Configurable_Product_Whith_Child_Image_Gallery
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

app/code/local/1eB/Catalog/Block/Product/View/Media.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class 1eB_Catalog_Block_Product_View_Media extends Mage_Catalog_Block_Product_View_Media
3
+ {
4
+ public function getGalleryImages()
5
+ {
6
+ $retChild = parent::getGalleryImages();
7
+ $current_product = $this->getProduct();
8
+ $parentIdArray = $current_product->loadParentProductIds()->getData('parent_product_ids');
9
+ if(is_array($parentIdArray) && count($parentIdArray)){
10
+ // Load the parent product model
11
+ $prodparent = Mage::getModel('catalog/product')->load($parentIdArray[0]);
12
+ $itemImages = $prodparent->getMediaGalleryImages();
13
+ if(count($retChild)){
14
+ foreach($retChild as $image){
15
+ $itemImages->addItem($image);
16
+ }
17
+ }
18
+ $retChild = $itemImages;
19
+ }
20
+ return $retChild;
21
+ }
22
+ }
23
+ ?>
app/code/local/1eB/Catalog/Helper/Image.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class 1eB_Catalog_Helper_Image extends Mage_Catalog_Helper_Image
3
+ {
4
+ public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile=null)
5
+ {
6
+ if (!$imageFile) {
7
+ $parentIdArray = $product->loadParentProductIds()->getData('parent_product_ids');
8
+ if(!empty($parentIdArray)){
9
+ $product = Mage::getModel('catalog/product')->load($parentIdArray[0]);
10
+ }
11
+ }
12
+ return parent::init($product, $attributeName, $imageFile);
13
+ }
14
+ }
15
+ ?>
app/code/local/1eB/Catalog/Model/Product.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Catalog
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Catalog product model
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Catalog
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Catalog_Model_Product extends Mage_Catalog_Model_Abstract
35
+ {
36
+ /**
37
+ * @deprecated after 1.4.2.0
38
+ * @return Mage_Catalog_Model_Product
39
+ */
40
+ public function loadParentProductIds()
41
+ {
42
+ return $this->setParentProductIds($this->_getResource()->getParentProductIds($this));
43
+ }
44
+ }
app/code/local/1eB/Catalog/Model/Resource/Eav/Mysql4/Product.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Catalog
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product entity resource model
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Catalog
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Catalog_Model_Resource_Eav_Mysql4_Product extends Mage_Catalog_Model_Resource_Eav_Mysql4_Abstract
35
+ {
36
+ /**
37
+ * @deprecated after 1.4.2.0
38
+ * @param $object Mage_Catalog_Model_Product
39
+ * @return array
40
+ */
41
+ public function getParentProductIds($object)
42
+ {
43
+ $childId = $object->getId();
44
+ $groupedProductsTable = $this->getTable('catalog/product_link');
45
+ $groupedLinkTypeId = Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED;
46
+ $configurableProductsTable = $this->getTable('catalog/product_super_link');
47
+
48
+ $groupedSelect = $this->_getReadAdapter()->select()
49
+ ->from(array('g'=>$groupedProductsTable), 'g.product_id')
50
+ ->where("g.linked_product_id = ?", $childId)
51
+ ->where("link_type_id = ?", $groupedLinkTypeId);
52
+
53
+ $groupedIds = $this->_getReadAdapter()->fetchCol($groupedSelect);
54
+
55
+ $configurableSelect = $this->_getReadAdapter()->select()
56
+ ->from(array('c'=>$configurableProductsTable), 'c.parent_id')
57
+ ->where("c.product_id = ?", $childId);
58
+
59
+ $configurableIds = $this->_getReadAdapter()->fetchCol($configurableSelect);
60
+ return array_merge($groupedIds, $configurableIds);
61
+ }
62
+ }
app/code/local/1eB/Catalog/etc/config.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <global>
4
+ <modules>
5
+ <1eB_Catalog>
6
+ <version>0.0.1</version>
7
+ </1eB_Catalog>
8
+ </modules>
9
+ <blocks>
10
+ <catalog>
11
+ <rewrite>
12
+ <product_view_media>1eB_Catalog_Block_Product_View_Media</product_view_media>
13
+ </rewrite>
14
+ </catalog>
15
+ </blocks>
16
+ <helpers>
17
+ <catalog>
18
+ <rewrite>
19
+ <image>1eB_Catalog_Helper_Image</image>
20
+ </rewrite>
21
+ </catalog>
22
+ </helpers>
23
+ </global>
24
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Configurable_Product_Whith_Child_Image_Gallery</name>
4
+ <version>0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>You can upload images on a child product, the gallery will be added to the configurable product gallery.</summary>
10
+ <description>Simply add parent product images to the child product gallery.&#xD;
11
+ &#xD;
12
+ Ajoute les images d'un produit configurable &#xE0; la gallerie du produit simple.</description>
13
+ <notes>Nothing.</notes>
14
+ <authors><author><name>Brunet</name><user>stab1eb</user><email>stephane@1eb.fr</email></author></authors>
15
+ <date>2011-09-23</date>
16
+ <time>12:47:00</time>
17
+ <contents><target name="magelocal"><dir name="1eB"><dir name="Catalog"><dir name="Block"><dir name="Product"><dir name="View"><file name="Media.php" hash="8c46a0819b4d301b10ec37d7c6f7f1a8"/></dir></dir></dir><dir name="Helper"><file name="Image.php" hash="997ad311b22d4bea60cdae880f0a6454"/></dir><dir name="Model"><file name="Product.php" hash="a9a6950c351be272b12a7d5d3b22345d"/><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Product.php" hash="0a25f775efc985ad8a2ab0bc4c6159e4"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="d432af123062abe6bb17f307cb669fed"/></dir></dir></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
20
+ </package>