How to get a product's image in Magento?

后端 未结 12 1113
慢半拍i
慢半拍i 2020-12-01 06:32

I\'m running on version 1.3.2.1, but on my client\'s server they had Magento 1.3.0 so my previous code to display images for my local copy,

echo $this->he         


        
12条回答
  •  离开以前
    2020-12-01 06:57

    // Let's load the category Model and grab the product collection of that category
    
    $product_collection = Mage::getModel('catalog/category')->load($categoryId)->getProductCollection();
    
    // Now let's loop through the product collection and print the ID of every product 
    foreach($product_collection as $product) {
      // Get the product ID
    
    $product_id = $product->getId();
    
      // Load the full product model based on the product ID
    
    $full_product = Mage::getModel('catalog/product')->load($product_id);
    
      // Now that we loaded the full product model, let's access all of it's data
    
      // Let's get the Product Name
    
      $product_name = $full_product->getName();
    
      // Let's get the Product URL path
    
      $product_url = $full_product->getProductUrl();
    
      // Let's get the Product Image URL
    
      $product_image_url = $full_product->getImageUrl();
    
      // Let's print the product information we gathered and continue onto the next one
    
     echo $product_name;
    
      echo $product_image_url;
    
    
    }
    

提交回复
热议问题