如何在magento中获取完整的产品图片网址,我需要将数据从magento迁移到 django所以我需要获取产品完整图片网址以迁移网站
这是我的代码
<?php
@ob_start();
@session_start();
ini_set('display_errors', 1);
//for order update
include '../../../../app/Mage.php';
Mage::app('default');
echo '<pre>';
if(isset($_REQUEST['productid'])){
$productId = $_REQUEST['productid'];
}else{
echo 'Default Product => ';
$productId = '12402'; // product ID 10 is an actual product, and used here for a test
}
$product = Mage::getModel('catalog/product')->load($productId); //load the product
print_r($product->getthumbnail());<br/>
print_r($product->getcreated_at());
?>
Run Code Online (Sandbox Code Playgroud)
Muf*_*dal 24
您可以首先尝试以下代码目录的所有呼叫帮助程序
echo Mage::helper('catalog/image')->init($product, 'thumbnail');
Run Code Online (Sandbox Code Playgroud)
从这段代码中你也可以获得缓存路径.
mpa*_*per 19
使用后加载产品后load()
,可以在代码中使用以下内容:
全尺寸图片:
$imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();
Run Code Online (Sandbox Code Playgroud)
调整大小/缓存图像:
$imageCacheUrl = Mage::helper('catalog/image')->init($product, 'image')->resize(135, 135);
Run Code Online (Sandbox Code Playgroud)
如果需要不同的缓存大小,请使用其他数字作为resize方法.
试试这个
$product = Mage::getModel('catalog/product')->load($product_id);
$full_path_url = Mage::helper('catalog/image')->init($product, 'thumbnail');
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
68166 次 |
最近记录: |