Magento
  • Personalization for Magento
  • Installing
  • Disconnecting
  • Uninstalling
  • Getting Started
  • Configuring
  • Guides
    • Varnish & Full-Page Caches
    • Advanced User Guide
    • Managing Blocks
    • Overriding or Extending Functionalities
      • Overriding Product Data
        • Excluding Products
        • Customising Pricing
        • Resizing Images
      • Overriding Customer Data
      • Overriding Line Item Data
    • Bulk Product Updates
    • Console Commands
  • Features
    • Variations (Configurable Products)
    • Add to Cart
    • Indexer
    • Customer Group Pricing
    • Supplier Cost & Inventory Level
    • Restore Cart Link
    • Ratings & Reviews
    • Multi Currency (Exchange Rates)
    • Marketing permission and GDPR compatibility
    • Catalog Price Rules
  • Integrations
    • Using Yotpo
    • Using Klarna
  • FAQ
  • Developing & Contributing
  • Visit Nosto
  • Issues
  • Releases
Powered by GitBook
On this page

Was this helpful?

  1. Guides
  2. Overriding or Extending Functionalities
  3. Overriding Product Data

Resizing Images

PreviousCustomising PricingNextOverriding Customer Data

Last updated 3 years ago

Was this helpful?

In order to use images with custom dimensions, you can use a built-in Magento re-sizer function to generate image URLs with the correct dimensions and you will need to amend the product model.

Start by reading and .

Note: In case you want a square image, only the first parameter is required.

File app/code/local/My/Nosto/Model/Meta/Product.php

<?php

/**
 * Overridden product meta data model.
 * This model is used as the data source when generating the tagging elements
 * on the product page, and when making server-to-server API calls to Nosto.
 */
class My_Nosto_Model_Meta_Product extends Nosto_Tagging_Model_Meta_Product
{
    /**
     * @inheritdoc
     */
    public function loadData(Mage_Catalog_Model_Product $product, Mage_Core_Model_Store $store = null)
    {
        parent::loadData($product, $store);

        $height = 300; 
        $width = 200;

        $image = (string)Mage::helper('catalog/image')
            ->init($product, 'thumbnail')
            ->resize($height, $width);

        $this->setImageUrl($image);

        return true;
    }
}
how to extend Nosto module
how to alter Nosto product data