src/ShopBundle/objects/db/TShopArticlePreviewImage.class.php
public function LoadByName(&$oArticle, $sInternalName)
    {
        $bLoaded = false;
        $this->oArticle = &$oArticle;
        $this->oImageSize = TdbShopArticleImageSize::GetNewInstance();
        /** @var $oImageSize TdbShopArticleImageSize */
        if ($this->oImageSize->LoadFromField('name_internal', $sInternalName)) {
            if ($this->LoadFromFields(array('shop_article_id' => $oArticle->id, 'shop_article_image_size_id' => $this->oImageSize->id))) {
                $bLoaded = true;
            } else {
                $oPrimaryImage = $oArticle->GetPrimaryImage();
                /** @var $oPrimaryImage TdbShopArticleImage */
                if (!is_null($oPrimaryImage)) {
                    $aData = array('cms_media_id' => $oPrimaryImage->sqlData['cms_media_id'], 'shop_article_image_size_id' => $this->oImageSize->id, 'shop_article_id' => $oArticle->id);
                    $this->LoadFromRow($aData);
                    $bLoaded = true;
                }
            }
        }

        return $bLoaded;
    }
public function LoadByName(&$oArticle, $sInternalName)
    {
        $bLoaded = false;
        $this->oArticle = &$oArticle;
        $this->oImageSize = TdbShopArticleImageSize::GetNewInstance();
        /** @var $oImageSize TdbShopArticleImageSize */
        if ($this->oImageSize->LoadFromField('name_internal', $sInternalName)) {
            if ($this->LoadFromFields(array('shop_article_id' => $oArticle->id, 'shop_article_image_size_id' => $this->oImageSize->id))) {
                $bLoaded = true;
            } else {
                $oPrimaryImage = $oArticle->GetPrimaryImage();
                /** @var $oPrimaryImage TdbShopArticleImage */
                if (!is_null($oPrimaryImage)) {
                    $aData = array('cms_media_id' => $oPrimaryImage->sqlData['cms_media_id'], 'shop_article_image_size_id' => $this->oImageSize->id, 'shop_article_id' => $oArticle->id);
                    $this->LoadFromRow($aData);
                    $bLoaded = true;
                }
            }
        }

        return $bLoaded;
    }
public function LoadByName ( & $ oArticle , $ sInternalName ) { $ bLoaded = false ; $ this -> oArticle = & $ oArticle ; $ this -> oImageSize = TdbShopArticleImageSize :: GetNewInstance ( ) ; /** @var $oImageSize TdbShopArticleImageSize */ if ( $ this -> oImageSize -> LoadFromField ( 'name_internal' , $ sInternalName ) ) { if ( $ this -> LoadFromFields ( array ( 'shop_article_id' => $ oArticle -> id , 'shop_article_image_size_id' => $ this -> oImageSize -> id ) ) ) { $ bLoaded = true ; } else { $ oPrimaryImage = $ oArticle -> GetPrimaryImage ( ) ; /** @var $oPrimaryImage TdbShopArticleImage */ if ( ! is_null ( $ oPrimaryImage ) ) { $ aData = array ( 'cms_media_id' => $ oPrimaryImage -> sqlData [ 'cms_media_id' ] , 'shop_article_image_size_id' => $ this -> oImageSize -> id , 'shop_article_id' => $ oArticle -> id ) ; $ this -> LoadFromRow ( $ aData ) ; $ bLoaded = true ; } } } return $ bLoaded ; }
return the image preview object. if the shop did not define one for this size,
then we create a virtual instance based on the first image of the article.

@param TdbShopArticle $oArticle      - the article object
@param string         $sInternalName - image size name

@return true
return the image preview object . if the shop did not define one for this size then we create a virtual instance based on the first image of the article .