2016-07-28 4 views
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> 

답변

0

실제로 문제의 원인은 레이블을 가져 오는 것입니다. 일부 속성은 프론트 엔드에서 볼 수 없으므로 저장소 레이블을 가져올 수 없습니다. Getter

$attribute->getIsVisibleOnFront() 

is_visible_on_front 속성의 설정 여부를 결정하는 데 도움이됩니다.

가져 오기 목적이 무엇이고 보이지 않는 속성을 포함해야하는지 확실하지 않습니다. 방법

$attribute->getFrontendLabel() 

은 관리자 패널 -> 속성 관리 페이지에서 표시되는 속성 값을 가져 오는 데 사용할 수 있습니다. 그러나 일부 속성 (나는 표 catalog_product_entity에서 추측)은 여전히 ​​비어 있습니다.

관련 문제