/** * Instantiate the correct Sku for a given product * * @return StorefrontModelProduct */ private function instantiateSkuForProduct($sId, $pId) { $warehouse = new Warehouse(); // If existing SKU, load the SKU, find the product, get the product type if ($sId) { $skuInfo = $warehouse->getSkuInfo($sId); $productType = $warehouse->getProductTypeInfo($skuInfo['info']->ptId)['ptName']; } else { $product = new Product($pId); $productType = $warehouse->getProductTypeInfo($product->getType())['ptName']; } // Initialize the correct SKU based on the product type if (!empty($productType) && $productType == 'Software Download') { require_once dirname(dirname(__DIR__)) . DS . 'models' . DS . 'SoftwareSku.php'; $sku = new \Components\Storefront\Models\SoftwareSku($sId); } else { require_once dirname(dirname(__DIR__)) . DS . 'models' . DS . 'Sku.php'; $sku = new \Components\Storefront\Models\Sku($sId); } // If this is a new SKU, set the product ID if (!$sId) { $sku->setProductId($pId); } return $sku; }