public function Product($forcecurrent = false)
    {
        //TODO: this might need some unit testing to make sure it compliles with comment description
        //ie use live if in cart (however I see no logic for checking cart status)
        if ($this->ProductID && $this->ProductVersion && !$forcecurrent) {
            return Versioned::get_version(Product::class, $this->ProductID, $this->ProductVersion);
        } elseif ($this->ProductID
            && $product = Versioned::get_one_by_stage(
                Product::class,
                'Live',
                '"SilverShop_Product"."ID"  = ' . $this->ProductID
            )
        ) {
            return $product;
        }
        return null;
    }
public function Product($forcecurrent = false)
    {
        //TODO: this might need some unit testing to make sure it compliles with comment description
        //ie use live if in cart (however I see no logic for checking cart status)
        if ($this->ProductID && $this->ProductVersion && !$forcecurrent) {
            return Versioned::get_version(Product::class, $this->ProductID, $this->ProductVersion);
        } elseif ($this->ProductID
            && $product = Versioned::get_one_by_stage(
                Product::class,
                'Live',
                '"SilverShop_Product"."ID"  = ' . $this->ProductID
            )
        ) {
            return $product;
        }
        return null;
    }
public function Product ( $ forcecurrent = false ) { //TODO: this might need some unit testing to make sure it compliles with comment description //ie use live if in cart (however I see no logic for checking cart status) if ( $ this -> ProductID && $ this -> ProductVersion && ! $ forcecurrent ) { return Versioned :: get_version ( Product :: class , $ this -> ProductID , $ this -> ProductVersion ) ; } elseif ( $ this -> ProductID && $ product = Versioned :: get_one_by_stage ( Product :: class , 'Live' , '"SilverShop_Product"."ID"  = ' . $ this -> ProductID ) ) { return $ product ; } return null ; }
Get related product
- live version if in cart, or
- historical version if order is placed

@param boolean $forcecurrent - force getting latest version of the product.

@return Product
Get related product - live version if in cart or - historical version if order is placed