Skip to content

Instantly share code, notes, and snippets.

@bastianccm
Created August 4, 2014 19:59
Show Gist options
  • Save bastianccm/f5505a767a9576129884 to your computer and use it in GitHub Desktop.
Save bastianccm/f5505a767a9576129884 to your computer and use it in GitHub Desktop.
<?php
$order = 13;
$attribute = 'url_key';
require_once 'app/Mage.php';
Mage::app();
/** @var Mage_Sales_Model_Order $order */
$order = Mage::getModel('sales/order')->load(1);
/** @var array $itemIds */
$itemIds = Mage::getResourceModel('sales/order_item_collection')->setOrderFilter($order)->getAllIds();
/** @var Mage_Catalog_Model_Resource_Product_Collection $productCollection */
$productCollection = Mage::getResourceModel('catalog/product_collection');
$productCollection->addFieldToFilter('entity_id', array('in' => $itemIds));
$productCollection->addAttributeToSelect($attribute);
foreach ($productCollection as $product) {
/** @var Mage_Catalog_Model_Product $product */
echo $product->getId() . ': ' . $product->getData($attribute) . PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment