src/ShopBundle/objects/db/TShopArticle.class.php
public function GetPrimaryImage()
    {
        $oPrimaryImage = &$this->GetFromInternalCache('oPrimaryImage');
        if (is_null($oPrimaryImage)) {
            if (!empty($this->fieldCmsMediaDefaultPreviewImageId) && (!is_numeric($this->fieldCmsMediaDefaultPreviewImageId) || intval($this->fieldCmsMediaDefaultPreviewImageId) > 1000)) {
                $oShop = TdbShop::GetInstance();
                $aData = array('shop_article_id' => $this->id, 'cms_media_id' => $this->fieldCmsMediaDefaultPreviewImageId, 'position' => 1);
                $oPrimaryImage = TdbShopArticleImage::GetNewInstance();
                $oPrimaryImage->LoadFromRow($aData);
            } else {
                $oImages = &$this->GetFieldShopArticleImageList();
                $activePage = $this->getActivePageService()->getActivePage();
                if (0 == $oImages->Length() && (!is_null($activePage))) {
                    $oShop = TdbShop::GetInstance();
                    $aData = array('shop_article_id' => $this->id, 'cms_media_id' => $oShop->fieldNotFoundImage, 'position' => 1);
                    $oPrimaryImage = TdbShopArticleImage::GetNewInstance();
                    $oPrimaryImage->LoadFromRow($aData);
                } else {
                    $oImages->GoToStart();
                    $oPrimaryImage = &$oImages->Current();
                }
            }

            if (false === $oPrimaryImage) {
                $oPrimaryImage = null;
                if ($this->IsVariant()) {
                    $oParent = $this->GetFieldVariantParent();
                    if (null != $oParent) {
                        $oPrimaryImage = $oParent->GetPrimaryImage();
                    }
                }
            }
            $this->SetInternalCache('oPrimaryImage', $oPrimaryImage);
        }

        return $oPrimaryImage;
    }
public function GetPrimaryImage()
    {
        $oPrimaryImage = &$this->GetFromInternalCache('oPrimaryImage');
        if (is_null($oPrimaryImage)) {
            if (!empty($this->fieldCmsMediaDefaultPreviewImageId) && (!is_numeric($this->fieldCmsMediaDefaultPreviewImageId) || intval($this->fieldCmsMediaDefaultPreviewImageId) > 1000)) {
                $oShop = TdbShop::GetInstance();
                $aData = array('shop_article_id' => $this->id, 'cms_media_id' => $this->fieldCmsMediaDefaultPreviewImageId, 'position' => 1);
                $oPrimaryImage = TdbShopArticleImage::GetNewInstance();
                $oPrimaryImage->LoadFromRow($aData);
            } else {
                $oImages = &$this->GetFieldShopArticleImageList();
                $activePage = $this->getActivePageService()->getActivePage();
                if (0 == $oImages->Length() && (!is_null($activePage))) {
                    $oShop = TdbShop::GetInstance();
                    $aData = array('shop_article_id' => $this->id, 'cms_media_id' => $oShop->fieldNotFoundImage, 'position' => 1);
                    $oPrimaryImage = TdbShopArticleImage::GetNewInstance();
                    $oPrimaryImage->LoadFromRow($aData);
                } else {
                    $oImages->GoToStart();
                    $oPrimaryImage = &$oImages->Current();
                }
            }

            if (false === $oPrimaryImage) {
                $oPrimaryImage = null;
                if ($this->IsVariant()) {
                    $oParent = $this->GetFieldVariantParent();
                    if (null != $oParent) {
                        $oPrimaryImage = $oParent->GetPrimaryImage();
                    }
                }
            }
            $this->SetInternalCache('oPrimaryImage', $oPrimaryImage);
        }

        return $oPrimaryImage;
    }
public function GetPrimaryImage ( ) { $ oPrimaryImage = & $ this -> GetFromInternalCache ( 'oPrimaryImage' ) ; if ( is_null ( $ oPrimaryImage ) ) { if ( ! empty ( $ this -> fieldCmsMediaDefaultPreviewImageId ) && ( ! is_numeric ( $ this -> fieldCmsMediaDefaultPreviewImageId ) || intval ( $ this -> fieldCmsMediaDefaultPreviewImageId ) > 1000 ) ) { $ oShop = TdbShop :: GetInstance ( ) ; $ aData = array ( 'shop_article_id' => $ this -> id , 'cms_media_id' => $ this -> fieldCmsMediaDefaultPreviewImageId , 'position' => 1 ) ; $ oPrimaryImage = TdbShopArticleImage :: GetNewInstance ( ) ; $ oPrimaryImage -> LoadFromRow ( $ aData ) ; } else { $ oImages = & $ this -> GetFieldShopArticleImageList ( ) ; $ activePage = $ this -> getActivePageService ( ) -> getActivePage ( ) ; if ( 0 == $ oImages -> Length ( ) && ( ! is_null ( $ activePage ) ) ) { $ oShop = TdbShop :: GetInstance ( ) ; $ aData = array ( 'shop_article_id' => $ this -> id , 'cms_media_id' => $ oShop -> fieldNotFoundImage , 'position' => 1 ) ; $ oPrimaryImage = TdbShopArticleImage :: GetNewInstance ( ) ; $ oPrimaryImage -> LoadFromRow ( $ aData ) ; } else { $ oImages -> GoToStart ( ) ; $ oPrimaryImage = & $ oImages -> Current ( ) ; } } if ( false === $ oPrimaryImage ) { $ oPrimaryImage = null ; if ( $ this -> IsVariant ( ) ) { $ oParent = $ this -> GetFieldVariantParent ( ) ; if ( null != $ oParent ) { $ oPrimaryImage = $ oParent -> GetPrimaryImage ( ) ; } } } $ this -> SetInternalCache ( 'oPrimaryImage' , $ oPrimaryImage ) ; } return $ oPrimaryImage ; }
return the primary image object of the shop article. this is either the cms_media_default_preview_image_id
or the  first image in the image list.

@return TdbShopArticleImage
return the primary image object of the shop article . this is either the cms_media_default_preview_image_id or the first image in the image list .