Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

richiamare un ATTRIBUTO con IF
 
ignition3d
Jr. Member
 
Total Posts:  12
Joined:  2012-10-05
Milano
 

salve a tutti,
ho un problema che non riesco a risolvere:

ho creato un nuovo attributo che viene visualizzato su ogni scheda prodotto come nella foto che ho postato.
però vorrei far comparire questo attributo nella scheda del prodotto, solo se il campo è compilato. altrimenti non deve apparire.

questo il codice che attualmente richiama l\\\’attributo nella scheda prodotto:

<class="availability in-stock">
        <
a href="#" onclick="window.open('<?php echo $this->htmlEscape($_product->getTechpage())?>' , 'targetWindow' , 'toolbar=no , location=no , status=no , menubar=no , scrollbars=no , resizable=no , width=520px , height=293px, left=400px ,top=130px ,')" />
        
<?php echo(" <img src=\"http://www.a2zonline.it/media/prodotti360/360ico.gif\">")?> </a></p>

forse con un IF, ma sinceramente non saprei dove e come agire.

grazie davvero per l’aiuto.

Image Attachments
img_attr.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
ignition3d
Jr. Member
 
Total Posts:  12
Joined:  2012-10-05
Milano
 

ecco il codice intero del file VIEW.PHTML

<?php?>
<?php $_helper 
$this->helper('catalog/output'); ?>
<?php $_product 
$this->getProduct(); ?>

<script type="text/javascript">
    var 
optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
</script>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<
div class="product-view">
    <
div class="product-name">
        <
h1><?php echo $_helper->productAttribute($_product$_product->getName(), 'name'?></h1>
    </
div>
    <
div class="product-essential">
    <
form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
        <
div class="no-display">
            <
input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
            <
input type="hidden" name="related_product" id="related-products-field" value="" />
        </
div>

        <
div class="product-shop">
            <
div class="ma-sku">
                
<?php echo 'SKU: <span>'.$_product->getSku().'</span>' ?>
             
</div>
            

    
        <
class="availability in-stock">
        <
a href="#" onclick="window.open('<?php echo $this->htmlEscape($_product->getTechpage())?>' , 'targetWindow' , 'toolbar=no , location=no , status=no , menubar=no , scrollbars=no , resizable=no , width=520px , height=293px, left=400px ,top=130px ,')" />
        
<?php echo(" <img src=\"http://www.a2zonline.it/media/prodotti360/360ico.gif\">")?> </a></p>
        
   
        

            
<?php echo $this->getChildHtml('product_type_data'?>
            <?php 
echo $this->getReviewsSummaryHtml($_productfalsetrue)?>
            <?php 
if ($_product->getShortDescription()):?>
                
<div class="short-description">
                    <!--<
h2><?php echo $this->__('Quick Overview'?></h2>-->
                    <
div class="std"><?php echo $_helper->productAttribute($_productnl2br($_product->getShortDescription()), 'short_description'?></div>
                </
div>
            
<?php endif;?>
            <?php 
echo $this->getChildHtml('alert_urls'?>
            
            <?php 
echo $this->getTierPriceHtml() ?>
            <?php 
echo $this->getChildHtml('extrahint'?>

            <?php 
if (!$this->hasOptions()):?>
                
<div class="add-to-box">
                    
<?php if($_product->isSaleable()): ?>
                        <?php 
echo $this->getChildHtml('addtocart'?>
                        <?php 
if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
                            
<!--<span class="or"><?php echo $this->__('OR'?></span>-->
                        
<?php endif; ?>
                    <?php 
endif; ?>
                    <?php 
echo $this->getChildHtml('addto'?>
                
</div>
                
<?php echo $this->getChildHtml('extra_buttons'?>
            <?php 
endif; ?>
            <?php 
if ($_product->isSaleable() && $this->hasOptions()):?>
                <?php 
echo $this->getChildChildHtml('container2'''truetrue?>
            <?php 
endif;?>
            
<div class="ma-social">
                
<?php if ($this->canEmailToFriend()): ?>
                    
<class="email-friend"><a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend'?></a></p>
                
<?php endif; ?>
                
<div class="social-link">
                    <!-- 
AddThis Button BEGIN -->
                    <
div class="addthis_toolbox addthis_default_style ">
                    <
class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
                    <
class="addthis_button_tweet"></a>
                    <
class="addthis_button_google_plusone" g:plusone:size="medium"></a>
                    </
div>
                    <
script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4ebf9cd355b286dd"></script>
                    
<!-- AddThis Button END -->
                </
div>
            </
div>

            
<?php echo $this->getChildHtml('other');?>

            <?php 
if ($_product->isSaleable() && $this->hasOptions()):?>
                <?php 
echo $this->getChildChildHtml('container1'''truetrue?>
            <?php 
endif;?>

        
</div>

        <
div class="product-img-box">
            
<?php echo $this->getChildHtml('media'?>
        
</div>

        <
div class="clearer"></div>
    </
form>
    <
script type="text/javascript">
    
//<![CDATA[
        
var productAddToCartForm = new VarienForm('product_addtocart_form');
        
productAddToCartForm.submit = function(buttonurl{
            
if (this.validator.validate()) {
                
var form this.form;
                var 
oldUrl form.action;

                if (
url{
                   form
.action url;
                
}
                
var null;
                try 
{
                    this
.form.submit();
                
catch (e{
                }
                this
.form.action oldUrl;
                if (
e{
                    
throw e;
                
}

                
if (button && button != 'undefined'{
                    button
.disabled true;
                
}
            }
        }
.bind(productAddToCartForm);

        
productAddToCartForm.submitLight = function(buttonurl){
            
if(this.validator{
                
var nv Validation.methods;
                
delete Validation.methods['required-entry'];
                
delete Validation.methods['validate-one-required'];
                
delete Validation.methods['validate-one-required-by-name'];
                if (
this.validator.validate()) {
                    
if (url{
                        this
.form.action url;
                    
}
                    this
.form.submit();
                
}
                Object
.extend(Validation.methodsnv);
            
}
        }
.bind(productAddToCartForm);
    
//]]>
    
</script>
    
</div>

    <
div class="product-collateral">
        
<?php echo $this->getChildHtml('info_tabs'?>
        <?php 
echo $this->getChildHtml('product_additional_data'?>
    
</div>
</
div>

grazie mille

 
Magento Community Magento Community
Magento Community
Magento Community
 
Black Cat
Moderator
 
Avatar
Total Posts:  3481
Joined:  2008-02-14
Assemini / Cagliari (Italy)
 

Prova così

<?php 
 
if ($_product->getData('attributo') != ""): ?>
 <?php 
echo $_product->getData('attributo'); ?>
<?php 
endif; ?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
ignition3d
Jr. Member
 
Total Posts:  12
Joined:  2012-10-05
Milano
 

perfetto.... questo il codice:

<?php if ($_product->getData('techpage') != ""): ?>
        
        
<class="availability in-stock">
        <
a href="#" onclick="window.open('<?php echo $this->htmlEscape($_product->getTechpage())?>' , 'targetWindow' , 'toolbar=no , location=no , status=no , menubar=no , scrollbars=no , resizable=no , width=520px , height=293px, left=400px ,top=130px ,')" />
        
<?php echo(" <img src=\"http://www.a2zonline.it/media/prodotti360/360ico.gif\">")?> </a></p>
        

        
<?php echo $_product->getData('techpage'); ?>
        <?php 
endif; ?>

grazie 1000

adesso viene fuori il pulsante solamente quando l’attributo ha un valore (cioè un LINK, infatti solo su un prodotto per ora).

ma c’è questo problema, guarda qua:
(mi viene visualizzato il link anche nella scheda prodotto)
http://www.a2zonline.it/lampada-faretto-led-mr16-gu5-3-12v-cob-5w-bianco-caldo.html

 
Magento Community Magento Community
Magento Community
Magento Community
 
Black Cat
Moderator
 
Avatar
Total Posts:  3481
Joined:  2008-02-14
Assemini / Cagliari (Italy)
 

basta ricreare il codice html intorno a quel valore rasberry

 
Magento Community Magento Community
Magento Community
Magento Community
 
ignition3d
Jr. Member
 
Total Posts:  12
Joined:  2012-10-05
Milano
 

fatto. :D grazie mille antonio per l’aiuto

ecco il codice definitivo

<?php if ($_product->getData('techpage') != ""): ?>
        
<class="availability in-stock">
        <
a href="#" onclick="window.open('<?php echo $this->htmlEscape($_product->getTechpage())?>' , 'targetWindow' , 'toolbar=no , location=no , status=no , menubar=no , scrollbars=no , resizable=no , width=520px , height=293px, left=400px ,top=130px ,')" />
        
<?php echo(" <img src=\"http://www.a2zonline.it/media/prodotti360/360ico.gif\">")?> </a></p>
        
<?php endif; ?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
ignition3d
Jr. Member
 
Total Posts:  12
Joined:  2012-10-05
Milano
 

Scusa Antonio,
secondo la tua esperienza è possibile far aprire questo link (<a href) in stile \"Lightbox\"??

secondo te si può fare?

GRAZIE
FAUSTO

 
Magento Community Magento Community
Magento Community
Magento Community
 
Black Cat
Moderator
 
Avatar
Total Posts:  3481
Joined:  2008-02-14
Assemini / Cagliari (Italy)
 

certo dipende dal plugin che intendi utilizzare e da come si implementa.

 
Magento Community Magento Community
Magento Community
Magento Community
 
dylogi
Jr. Member
 
Total Posts:  2
Joined:  2014-03-11
 

Buongiorno,

io avrei un esigenza simile, non voglio modificare il file.phtml ma bensì inserire il richiamo attributo nella descrizione prodotto catalogo->gestione prodotti. In questo modo dopo una breve formazione il cliente potrebbe utilizzare tale sistema per descrivere il prodotto e dinamicamente visualizzare i valori degli attributi.

qualcuno puo aiutarmi? é urgente

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top