KJ\Magento\Command\Order\Create\DummyCommand::getProduct PHP Method

getProduct() protected method

protected getProduct ( ) : Mage_Catalog_Model_Product
return Mage_Catalog_Model_Product
    protected function getProduct()
    {
        if (isset($this->_product)) {
            return $this->_product;
        }
        $productInput = $this->_input->getOption('product');
        if ($productInput && !preg_match('/%/', $productInput)) {
            /** @var \Mage_Catalog_Model_Product $product */
            $product = \Mage::getModel('catalog/product');
            $product->loadByAttribute('sku', $productInput);
            if (!$product) {
                throw new \Exception("Couldn't find product by SKU: " . $productInput);
            }
            $product = \Mage::getModel('catalog/product')->load($product->getId());
        } else {
            $product = $this->_loadRandomProduct($productInput);
        }
        $this->_product = $product;
        return $this->_product;
    }