N98\Magento\Command\Developer\Translate\ExportCommand::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer | void
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
return integer | void
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->detectMagento($output);
        if (!$this->initMagento()) {
            return;
        }
        /** @var DatabaseHelper $helper */
        $helper = $this->getHelper('database');
        $db = $helper->getConnection();
        $filename = $input->getArgument('filename');
        if (!$filename) {
            $filename = 'translate.csv';
        }
        $locale = $input->getArgument('locale');
        $output->writeln('Exporting to <info>' . $filename . '</info>');
        $parameters = array('locale' => $locale);
        $sql = "SELECT * FROM core_translate WHERE locale = :locale";
        if ($input->getOption('store')) {
            $sql .= ' AND store_id = :store_id';
            $parameters['store_id'] = Mage::app()->getStore($input->getOption('store'));
        }
        $statement = $db->prepare($sql);
        $statement->execute($parameters);
        $result = $statement->fetchAll();
        $f = fopen($filename, 'w');
        foreach ($result as $row) {
            fputcsv($f, array($row['string'], $row['translate']));
        }
        fclose($f);
    }