You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Pimcore中导出多语言商品目录CSV?西班牙语设置问题求助

Fixing Pimcore Spanish Language Display & Exporting Product Catalog CSV

Hey there! Let's work through your two issues: getting Spanish to show up as the active language in your data objects, then exporting the Spanish product catalog as a CSV.

First: Resolve the Spanish Language Not Showing Up Issue

This is almost always a cache or configuration oversight—let's go through the checks step by step:

  • Verify System-Wide Language Setup

    1. Head to Settings > System Settings > Localization
    2. First, make sure Spanish (es) is added to the Available Languages list (if not, click "Add Language" and select it)
    3. Set Spanish as the Default Language
    4. Critical Step: Clear Pimcore's full cache. Don't just refresh the browser—click the cache icon in the top-right corner of the admin, or run this command in your terminal:
      bin/console pimcore:cache:clear
      

    Browser cache can also interfere, so try reloading in incognito mode after clearing Pimcore's cache.

  • Check Data Object Class Localization
    If Spanish is showing up in system settings but not on individual product objects, your product class might not have localization enabled for fields:

    1. Go to Settings > Data Objects > Classes and open your product class
    2. For every field that needs Spanish translations (e.g., product name, description), edit the field and check the Localization box for Spanish
    3. Save the class, then clear the cache again (yes, again—Pimcore loves cache clears!)
  • User Session & Permissions Check
    Sometimes a cached user session can stick to the old default language. Try logging out and back in, or using an admin account to confirm permissions aren't restricting language access.

Second: Export Spanish Product Catalog as CSV

Once Spanish is properly set up, you have two reliable ways to export:

Option 1: Use Pimcore's Built-In Export Tool (No Code Needed)

  1. Navigate to Data Objects and filter the product list to include only the items you want to export
  2. Click the Export button at the top of the list view
  3. In the export configuration modal:
    • Select CSV as the export format
    • In the Language dropdown, you should now see Spanish (es) (if not, double-check the steps above)
    • Check the boxes for all fields you want to export—localized fields will automatically pull their Spanish values
    • Set encoding to UTF-8 (critical for special Spanish characters like ñ, á) and choose your preferred delimiter
    • Click "Export" to download the CSV

Option 2: Custom Console Command (For Automation/Batch Exports)

If you need to automate exports or handle large datasets, a custom Symfony command works great. Here's a simplified example:

<?php
namespace App\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Pimcore\Model\DataObject\Product;
use League\Csv\Writer;

class ExportSpanishProductsCommand extends Command
{
    protected static $defaultName = 'app:export-spanish-products';

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        // Initialize CSV writer with UTF-8 encoding
        $csv = Writer::createFromString('');
        $csv->setOutputBOM(Writer::BOM_UTF8);
        // Add header row
        $csv->insertOne(['Product ID', 'Nombre (ES)', 'Descripción (ES)', 'Precio']);

        // Fetch products with Spanish locale
        $productListing = new Product\Listing();
        $productListing->setLocale('es'); // Forces Spanish translations

        foreach ($productListing->getItems() as $product) {
            $csv->insertOne([
                $product->getId(),
                $product->getName(), // Pulls Spanish value automatically
                $product->getDescription(),
                $product->getPrice() // Non-localized field example
            ]);
        }

        // Save to server or output to console
        $exportPath = '/var/www/html/public/spanish_products.csv';
        file_put_contents($exportPath, $csv->toString());
        
        $output->writeln(sprintf('Spanish product export saved to: %s', $exportPath));
        return Command::SUCCESS;
    }
}

To run this command:

bin/console app:export-spanish-products

Quick Notes to Avoid Headaches

  • Make sure your products actually have Spanish translations filled in—empty fields will show up as blanks in the CSV
  • Always clear cache after changing language or class settings—this is the #1 fix for most Pimcore localization issues
  • For special characters, stick to UTF-8 encoding to prevent garbled text in the CSV

内容的提问来源于stack exchange,提问作者mr0b0t0

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 07:43:44