0
下面的代碼是爲獲取所需的產品信息而編寫的,但我也想獲取產品的類別url,請任何人都可以幫助我在同一個循環中獲取url 。如何獲取magento中產品的類別url
<?php
error_reporting(E_ALL | E_STRICT);
define('MAGENTO_ROOT', getcwd());
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
Mage::app();
$products = Mage::getModel("catalog/product")->getCollection();
$products->addAttributeToSelect(array('name','price','producturl','image'));
$products->addAttributeToSelect('categoryurl'); // Is this correct
$products->addAttributeToFilter('status', 1);
$products->addAttributeToFilter('visibility', 4);
foreach ($products as $product){
$sku = $product->getSku();
$name = $product->getName();
$currentCat = $product->getCategoryUrl(); // I want to fetch the category url of the product
}
?>
謝謝,它的工作... – 2014-11-03 08:44:34