0
나는 내 제품 데이터를 모두 내보내도록이 스크립트를 작성했습니다. <admin>
매듭까지 작동합니다. 속성의 레이블을 얻는 데 문제가있는 것처럼 보입니다.제품의 모든 속성 내보내기
<?php $productCollection = Mage::getModel('catalog/product')->getCollection(); ?>
<?php echo '<?xml version="1.0" encoding="utf-8"?>'.PHP_EOL; ?>
<import>
<?php if (!empty($productCollection)): ?>
<?php /** @var Mage_Catalog_Model_Product $product */ ?>
<?php foreach ($productCollection as $product): ?>
<product>
<?php $websiteIds = $product->getWebsiteIds(); ?>
<?php if (!empty($websiteIds)): ?>
<websites>
<?php foreach ($websiteIds as $websiteId): ?>
<website>
<?php $website = Mage::getModel('core/website')->load($websiteId); ?>
<code><?php echo $website->getName(); ?></code>
<?php $storeIds = $website->getStoreIds(); ?>
<?php if(!empty($storeIds)): ?>
<store_views>
<?php foreach ($storeIds as $storeId): ?>
<?php $store = Mage::getModel('core/store')->load($storeId); ?>
<code><?php echo $store->getName(); ?></code>
<?php endforeach; ?>
</store_views>
<?php endif; ?>
</website>
<?php endforeach; ?>
</websites>
<?php endif; ?>
<?php $categoryIds = $product->getCategoryIds(); ?>
<?php if (!empty($categoryIds)): ?>
<categories>
<?php foreach ($categoryIds as $categoryId): ?>
<id><?php echo $categoryId; ?></id>
<?php endforeach; ?>
</categories>
<?php endif; ?>
<admin>
<?php $attributes = $product->getAttributes(); ?>
<?php if (!empty($attributes)): ?>
<?php foreach ($attributes as $attribute): ?>
<attribute>
<name><?php echo $attribute->getStoreLabel($product); ?></name>
<value><?php echo $attribute->getFrontend()->getValue($product); ?></value>
</attribute>
<?php endforeach; ?>
<?php endif; ?>
</admin>
<?php if (!empty($storeIds)): ?>
<?php foreach ($storeIds as $storeId): ?>
<store_view>
<?php $store = Mage::getModel('core/store')->load($storeId); ?>
<code><?php echo $store->getName(); ?></code>
<?php Mage::app()->setCurrentStore($storeId); ?>
<?php $attributes = $product->getAttributes(); ?>
<?php if (!empty($attributes)): ?>
<attributes>
<?php foreach ($attributes as $attribute): ?>
<attribute>
<name><?php echo $attribute->getStoreLabel($product); ?></name>
<value><?php echo $attribute->getFrontend()->getValue($product); ?></value>
</attribute>
<?php endforeach; ?>
</attributes>
<?php endif; ?>
</store_view>
<?php endforeach; ?>
<?php endif; ?>
</product>
<?php endforeach; ?>
<?php endif; ?>
</import>