N98\Magento\Command\Customer\ListCommand::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, true);
        if (!$this->initMagento()) {
            return;
        }
        $config = $this->getCommandConfig();
        $collection = $this->getCustomerCollection();
        $collection->addAttributeToSelect(array('entity_id', 'email', 'firstname', 'lastname', 'website_id'));
        if ($input->getArgument('search')) {
            $collection->addAttributeToFilter(array(array('attribute' => 'email', 'like' => '%' . $input->getArgument('search') . '%'), array('attribute' => 'firstname', 'like' => '%' . $input->getArgument('search') . '%'), array('attribute' => 'lastname', 'like' => '%' . $input->getArgument('search') . '%')));
        }
        $collection->setPageSize($config['limit']);
        $table = array();
        foreach ($collection as $customer) {
            $table[] = array($customer->getId(), $customer->getEmail(), $customer->getFirstname(), $customer->getLastname(), $this->_getWebsiteCodeById($customer->getwebsiteId()));
        }
        if (count($table) > 0) {
            $this->getHelper('table')->setHeaders(array('id', 'email', 'firstname', 'lastname', 'website'))->renderByFormat($output, $table, $input->getOption('format'));
        } else {
            $output->writeln('<comment>No customers found</comment>');
        }
    }