What does this PHP line mean? 'is_in_stock' => $itemColourSizeFlat->getQuantityA

I need help understanding this line of code and ultimately converting it to one that solves the problem I am facing for my magento site.

[php]‘is_in_stock’ => $itemColourSizeFlat->getQuantityAvailable() > 0 ? 1 : 0,[/php]

It is an extract from my inventory update process. The problem I have is when I sync my inventory with my external system, products with qty <1 are marked “out of stock”. This is a problem because some products have a backorder status of “allow backorders”. If the status is allow backorders (or allow backorders and notify customer) I want the stock status to remain “in stock”.

for context, this line of code sites together with these lines:

[php]/**
* Prepare data for simple products.
*
* @param $itemColourSizeFlat
* @param string $mode
* @return mixed
*/
protected function _prepareDataSimple ($itemColourSizeFlat, $mode = self::MODE_CREATE)
{
$preparedAttributes = $this->_prepareData($itemColourSizeFlat);
$preparedAttributes = $this->_prepareDataSimpleFinalPrice($itemColourSizeFlat, $preparedAttributes);
$preparedAttributes[‘type_id’] = Mage_Catalog_Model_Product_Type::TYPE_SIMPLE;
$preparedAttributes[‘stock_data’] = array(
‘is_in_stock’ => $itemColourSizeFlat->getQuantityAvailable() > 0 ? 1 : 0,
‘qty’ => $itemColourSizeFlat->getQuantityAvailable(),
);

foreach ($this->_simpleProductNameUniqueness as $attribute => $originalAttribute)
{
    if (!array_key_exists($attribute, $preparedAttributes))
    {
        continue;
    }

    // @TODO FIX THIS usingaccumulated data per product group..
    $preparedAttributes['name'] = $preparedAttributes['name'] .
        ' ' .
        $preparedAttributes[$attribute.self::LABEL_DATA_APPEND];
}[/php]

Background. I’m not a developer and my dev is not contactable today. I really need to fix this, so I’m trying to teach myself PHP today to do so. It is very hard so far! Any help would be very much appreciated

[php]‘is_in_stock’ => $itemColourSizeFlat->getQuantityAvailable() > 0 ? 1 : 0,[/php]

‘is_in_stock’ is a member of an array.
$itemColourSizeFlat is an instance of a class.
getQuantityAvailable() this calls a method of the class instantiated by, $itemColourSizeFlat

0 ? 1 : 0 is the last portion of a ternary.

So, if the return value is greater than 0 (in stock), is_in_stock equals true, else it equals false.

Sponsor our Newsletter | Privacy Policy | Terms of Service