/** * Prepare product * * @param array $productRow * @return Varien_Object */ protected function _prepareProduct(array $productRow) { $product = parent::_prepareProduct($productRow); $attribute = Mage::getSingleton('catalog/product')->getResource()->getAttribute('media_gallery'); $media = Mage::getResourceSingleton('catalog/product_attribute_backend_media'); $gallery = $media->loadGallery($product, new Varien_Object(array('attribute' => $attribute))); $product->setGallery($gallery); return $product; }
/** * Filter results to only contain NOT LOGGED IN visible entities. * * This method is only called in EE versions >= 1.13 and CE versions >= 1.8. * For older versions the filter is added by overloading the method _addFilter. * * I'm aware I could simply omit the overloading of _loadEntities and use * the _addFilter overload for any version, but I might drop support for older * versions in future and then I only need to clean up the _addFilter hack to * have a cleaner implementation again. * * @return array * @see self::_addFilter() */ protected function _loadEntities() { $this->_addNotLoggedInGroupFilter(); return parent::_loadEntities(); }
/** * Test getCollection None images * 1) Check that image attributes were not loaded * 2) Check no images were loaded * 3) Check thumbnails when no thumbnail selected * * @magentoConfigFixture default_store sitemap/product/image_include base */ public function testGetCollectionBase() { $model = new Mage_Sitemap_Model_Resource_Catalog_Product(); $products = $model->getCollection(Mage_Core_Model_App::DISTRO_STORE_ID); $this->_checkProductCollection($products, 3, array(1, 4, 5)); // Check name attribute was loaded foreach ($products as $product) { $this->assertNotEmpty($product->getName(), 'name attribute was not loaded'); } // Check thumbnail attribute $this->assertEmpty($products[1]->getImage(), 'image attribute was loaded'); $this->assertEmpty($products[4]->getThumbnail(), 'thumbnail attribute was loaded'); $this->assertEquals('/s/e/second_image.png', $products[4]->getImage(), 'Incorrect image attribute'); // Check images loading $this->assertEmpty($products[1]->getImages(), 'Images were loaded'); $this->assertNotEmpty($products[4]->getImages(), 'Images were not loaded'); $this->assertEquals('Simple Images', $products[4]->getImages()->getTitle(), 'Incorrect title'); $this->assertEquals('catalog/product/s/e/second_image.png', $products[4]->getImages()->getThumbnail(), 'Incorrect thumbnail'); $this->assertCount(1, $products[4]->getImages()->getCollection(), 'Number of loaded images is incorrect'); $imagesCollection = $products[4]->getImages()->getCollection(); $this->assertEquals('catalog/product/s/e/second_image.png', $imagesCollection[0]->getUrl(), 'Incorrect image url'); $this->assertEmpty($imagesCollection[0]->getCaption(), 'Caption not empty'); // Check no selection $this->assertEmpty($products[5]->getThumbnail(), 'thumbnail is not empty'); $this->assertEquals('no_selection', $products[5]->getImage(), 'image is incorrect'); $this->assertEmpty($products[5]->getImages(), 'Product images were loaded'); }