protected function _afterLoad() { parent::_afterLoad(); if (!$this->isExtensionConfigured()) { return $this; } foreach ($this->_klevu_parent_child_ids as $item) { if ($item['parent_id'] > 0) { /** @var Mage_Catalog_Model_Product $parent */ $parent = $this->_items[$item['parent_id']]; /** @var Mage_Catalog_Model_Product $child */ $child = ''; if (isset($this->_items[$item['product_id']])) { $child = $this->_items[$item['product_id']]; } // Parent isn't visible. Unset both child and parent products and skip. if (!$parent || !$this->_isProductVisible($parent)) { unset($this->_items[$item['parent_id']], $this->_items[$item['product_id']]); continue; } if ($child) { // Set children images on parent product $image = $child->getData('image'); if ($child->getData('image') != 'no_selection' && !empty($image)) { $parent->setData('image', $image); } $small_image = $child->getData('small_image'); if ($child->getData('small_image') != 'no_selection' && !empty($small_image)) { $parent->setData('small_image', $small_image); } $thumbnail = $child->getData('thumbnail'); if ($child->getData('thumbnail') != 'no_selection' && !empty($thumbnail)) { $parent->setData('thumbnail', $thumbnail); } } unset($this->_items[$item['product_id']]); } // If the child exists, but isn't visible unset the item from our collection. if (isset($this->_items[$item['product_id']]) && !$this->_isProductVisible($this->_items[$item['product_id']])) { unset($this->_items[$item['product_id']]); } } return $this; }