Exemplo n.º 1
0
 /**
  * Generate item array for template
  * @param   ProductCollectionItem
  * @return  array
  */
 protected function generateItem(ProductCollectionItem $objItem)
 {
     $blnHasProduct = $objItem->hasProduct();
     $objProduct = $objItem->getProduct();
     // Set the active product for insert tags replacement
     if ($blnHasProduct) {
         Product::setActive($objProduct);
     }
     $arrCSS = $blnHasProduct ? deserialize($objProduct->cssID, true) : array();
     $arrItem = array('id' => $objItem->id, 'sku' => $objItem->getSku(), 'name' => $objItem->getName(), 'options' => Isotope::formatOptions($objItem->getOptions()), 'quantity' => $objItem->quantity, 'price' => Isotope::formatPriceWithCurrency($objItem->getPrice()), 'tax_free_price' => Isotope::formatPriceWithCurrency($objItem->getTaxFreePrice()), 'total' => Isotope::formatPriceWithCurrency($objItem->getTotalPrice()), 'tax_free_total' => Isotope::formatPriceWithCurrency($objItem->getTaxFreeTotalPrice()), 'tax_id' => $objItem->tax_id, 'href' => false, 'hasProduct' => $blnHasProduct, 'product' => $objProduct, 'item' => $objItem, 'raw' => $objItem->row(), 'rowClass' => trim('product ' . ($blnHasProduct && $objProduct->isNew() ? 'new ' : '') . $arrCSS[1]));
     if (null !== $objItem->getRelated('jumpTo') && $blnHasProduct && $objProduct->isAvailableInFrontend()) {
         $arrItem['href'] = $objProduct->generateUrl($objItem->getRelated('jumpTo'));
     }
     Product::unsetActive();
     return $arrItem;
 }
 /**
  * @category ISO_HOOKS: itemIsAvailable
  *
  * @param ProductCollectionItem|\Model $item
  *
  * @return false|null Return false but never true
  */
 public function checkItemIsAvailable(ProductCollectionItem $item)
 {
     /** @var Product|\Model $product */
     $product = $item->getProduct();
     /** @var ProductType|\Model $productType */
     $productType = $product->getRelated('type');
     if (!$productType->stockmanagement_active) {
         return null;
     }
     $stock = Stock::getStockForProduct($product->id);
     if (false !== $stock && $stock < 1) {
         return false;
     }
     return null;
 }