Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Mage::app() e attributi custom
 
oscarino
Jr. Member
 
Total Posts:  22
Joined:  2010-05-23
 

Ciao,
sto provando a connettermi al db di Magento utilizzando uno script phph esterno.
Tuttu i prodotti vengono mostrati corrattamente ma non so come mostrare anche gli attributi custom (che ho creato utilizzando l’Admin di Magento - “Manage Attributes” e “Manage Attributes Sets").

Potreste aiutarmi?
Grazie.

----------------------------------------------
Ecco il codice che sto utilizzando
----------------------------------------------

<?php

require_once("shop/app/Mage.php");
Mage::app();

$category = new Mage_Catalog_Model_Category();
$category->getAllChildren(11);

$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToFilter('status', 1);
$products->addCategoryFilter($category);
$products->addAttributeToSelect('sku');
$prodIds=$products->getAllIds();
$product = Mage::getModel('catalog/product');
$count=1;

foreach($prodIds as $productId)
{
echo "$count <br>";
$product->load($productId);
$custimAttr = $product->getProductCustomAttribute();
$product_data = array();
$product_data ['attrib']= $product->getTest();
$product_data['sku']=$product->getSku();
$product_data['title']=$product->getName();
$product_data['description']=$product->getDescription();
$product_data['link']=$product->getProductUrl();
$product_data['image_link']=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage();
$product_data['price']=$product->getPrice();
$product_data['brand']=$product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($product);
$product_data['product_type']=$product->getType();
$attribute = Mage::getModel('catalog/product')
->setStoreId(0)
->getResource()
->getAttribute('home_new');
echo "<pre>";
print_r ($product_data);
echo "</pre>";

//get the product categories
foreach($product->getCategoryIds() as $_categoryId){
$category = Mage::getModel('catalog/category')->load($_categoryId);
$product_data['product_type'].=$category->getName().', ';
}
$product_data['product_type']=rtrim($product_data['product_type'],', ');
}
?>

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top