2015-03-09 2 views
0

Мне нужно проверить строку и заменить, если атрибут равен «Destaque:» в случае, когда атрибут соответствует ему, не удается распечатать строку, но я запутался с функциями, может кто-нибудь Помогите мне?заменить строку в таблице

<?php 

class Produto_Atributo 
{ 
    function __construct() 
    { 
    } 


    function produtoAtributo($codigo) 
    { 
     Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); 

     $banco_magento = Mage::getSingleton('core/resource')->getConnection('core_write'); 


     $sql = "SELECT * FROM tw_produto_atributo where entity_id=" . $codigo; 


     $resultadoSql = $banco_magento->fetchAll($sql); 

     $count = 0; 

     foreach ($resultadoSql as $linha) { 

      $classe = ''; 

      if ($count % 2 == 0) { 
       $classe = 'par'; 
      } 
      else { 
       $classe = 'impar'; 
      } 

      $_atributo = $this->recuperarAtributo($linha['attribute_id']); 


      $_optionText = $this->recuperarOptionid($_atributo, $linha['option_id']); 
      $descricao=$linha['ds_conteudo'] ; 
      $order = array("\n"); 
      $replace = '<br />'; 
      $newstr = str_replace($order, $replace, $descricao); 


      if (isset($linha['ds_conteudo']) && $linha['ds_conteudo'] != '') { 
       echo '<tr class="active '.$classe.'"> 

       <td class="table-caracteristica-titulo" style="padding-left: 45px !important;padding-right: 45px !important; "> ' . ucwords(strtolower($_optionText)) . '</td> 

       <td class="table-caracteristica-descricao" style="padding-left: 45px !important;padding-right: 45px !important;"> ' . $newstr. '</td> 
      </tr>'; 
      } else { 
       echo '<tr class="'.$classe.'"> 
       <td class="table-caracteristica-titulo" style="padding-left: 45px !important;padding-right: 45px !important;">'if($_atributo->getFrontend_label()==!"Destaque:"){$_atributo->getFrontend_label();}else {'Loko'.$_atributo->getFrontend_label();} '</td> 

       <td class="table-caracteristica-descricao" style="padding-left: 45px !important;padding-right: 45px !important;"> ' . $_optionText . '</td> 
       </tr>'; 
      } 

      $count = $count + 1; 

     } 
    } 

    function recuperarAtributo($atributo) 
    { 

     $cod = $atributo; 

     $attr = Mage::getModel('eav/entity_attribute')->getCollection()->addFieldToFilter('attribute_id', array('eq' => $cod))->getFirstItem(); 

     return $attr; 

    } 

    function recuperarOptionid($atributo, $option_id) 
    { 

     return ($atributo->getSource()->getOptionText($option_id)); 

    } 
} 

ответ

0

уже получил Хаха был очень прост, вот ответ:

if (isset($linha['ds_conteudo']) && $linha['ds_conteudo'] != '') { 
       echo '<tr class="active '.$classe.'"> 

       <td class="table-caracteristica-titulo" style="padding-left: 45px !important;padding-right: 45px !important; "> ' . ucwords(strtolower($_optionText)) . '</td> 

       <td class="table-caracteristica-descricao" style="padding-left: 45px !important;padding-right: 45px !important;"> ' . $newstr. '</td> 
      </tr>'; 
      } else { 
       if($_atributo->getFrontend_label()<>"Destaque:"){ 
        echo '<tr class="'.$classe.'"> 
         <td class="table-caracteristica-titulo" style="padding-left: 45px !important;padding-right: 45px !important;">' . $_atributo->getFrontend_label() . '</td> 

         <td class="table-caracteristica-descricao" style="padding-left: 45px !important;padding-right: 45px !important;"> ' . $_optionText . '</td> 
         </tr>'; 
       } 

      } 
Смежные вопросы