Back to PhocacartStock class

Method getStockStatusData

public static
getStockStatusData
(mixed $stockStatusId, mixed $available = 1)

Method getStockStatusData - Source code

public static function getStockStatusData($stockStatusId, $available = 1)
{
    $db = Factory::getDBO();
    if ($available == 1) {
        $statusMethod = 'p.stockstatus_a_id';
        // Status when product is in stock A(P > 0), or stock is not checked
    } else {
        $statusMethod = 'p.stockstatus_n_id';
        // Status when product is not in stock N(P = 0)
    }
    $columns = 's.id, s.title, s.title_feed, s.image';
    $groupsFull = $columns;
    $groupsFast = 's.id';
    $groups = PhocacartUtilsSettings::isFullGroupBy() ? $groupsFull : $groupsFast;
    $query = 'SELECT s.id, s.title, s.title_feed, s.image, s.link, s.link_target' . ' FROM #__phocacart_stock_statuses AS s' . ' LEFT JOIN #__phocacart_products AS p ON s.id = ' . $statusMethod . ' WHERE s.id = ' . (int) $stockStatusId . ' GROUP BY ' . $groups . ' ORDER BY s.id';
    $db->setQuery($query);
    $data = $db->loadObjectList();
    return $data;
}