Jump to content

Ocultar un <div> según categoría


angeldavo

Recommended Posts

Debes de sobreescribir la classe Product.php y añadir el nuevo campo mediante un override, asi por ejemplo

<?php
class Product extends ProductCore
{

  public $nuevo_campo;
  public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
 {
  Product::$definition['fields']['nuevo_campo'] = array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
   parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
 }
 }

Luego ya puedes utilizarlo desde el ProductController y se te debería guardar

Link to comment
Share on other sites

En classes/product.php he creado estas las nuevas variables

Para el nuevo espacio para escribir    
    public $new_send;
    public $new_carac;
    public $new_other;
    public $new_joyas;

Para el checkbox de cada espacio  
    public $show_txt;
    public $show_txt1;
    public $show_tx2;
    public $show_tx3;

    'new_send' =>                array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
    'new_carac' =>                array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
    'new_other' =>                array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
    'new_joyas' =>                array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),

Luego he creado las fediniciones
    'show_txt' =>                array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
    'show_txt1' =>                array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
    'show_txt2' =>                array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
    'show_txt3' =>                array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),

Luego en /admin/themes/default/template/controllers/products/informations.tpl he creado he creado los espacios en cada producto

<div class="form-group">

		<div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="description_short" type="tinymce" multilang="true"}</span></div>
		<label class="control-label col-lg-2" for="description_short_{$id_lang}">
			<span class="label-tooltip" data-toggle="tooltip" title="{l s='Appears in the product list(s), and at the top of the product page.'}">
				<input type="checkbox" id="show_txt" name="show_txt" class="ac_input" value="1" {if $product->show_txt == 0} checked="true" {/if} />
				{l s='Características Técnicas / Información adicional'}
			</span>
		</label>
		<div class="col-lg-9">
			{include
				file="controllers/products/textarea_lang.tpl"
				languages=$languages
				input_name='new_carac'
				class="autoload_rte"
				input_value=$product->new_carac
				max=$PS_PRODUCT_SHORT_DESC_LIMIT}
		</div>
	</div>

	<div class="form-group">
		<div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="description_short" type="tinymce" multilang="true"}</span></div>
		<label class="control-label col-lg-2" for="description_short_{$id_lang}">
			<span class="label-tooltip" data-toggle="tooltip" title="{l s='Appears in the product list(s), and at the top of the product page.'}">
				
				<input type="checkbox" id="show_txt1" name="show_txt1" class="ac_input" value="1" {if $product->show_txt1 != 0} checked="true" {/if}/>
				{l s='Detalles del envío'}
			</span>
		</label>
		<div class="col-lg-9">
			{include
				file="controllers/products/textarea_lang.tpl"
				languages=$languages
				input_name='new_send'
				class="autoload_rte"
				input_value=$product->new_send
				max=$PS_PRODUCT_SHORT_DESC_LIMIT}
		</div>
	</div>

	<div class="form-group">
		<div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="description_short" type="tinymce" multilang="true"}</span></div>
		<label class="control-label col-lg-2" for="description_short_{$id_lang}">
			<span class="label-tooltip" data-toggle="tooltip" title="{l s='Appears in the product list(s), and at the top of the product page.'}">
				<input type="checkbox" id="show_txt2" name="show_txt2" class="ac_input" value="1" {if $product->show_txt2 != 0} checked="true" {/if} />
				{l s='Consejo sobre el cuidado del producto'}
			</span>
		</label>
		<div class="col-lg-9">
			{include
				file="controllers/products/textarea_lang.tpl"
				languages=$languages
				input_name='new_other'
				class="autoload_rte"
				input_value=$product->new_other
				max=$PS_PRODUCT_SHORT_DESC_LIMIT}
		</div>
	</div>

	<div class="form-group">
		<div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="description_short" type="tinymce" multilang="true"}</span></div>
		<label class="control-label col-lg-2" for="description_short_{$id_lang}">
			<span class="label-tooltip" data-toggle="tooltip" title="{l s='Appears in the product list(s), and at the top of the product page.'}">
				<input type="checkbox" id="show_txt3" name="show_txt3" class="ac_input" value="1" {if $product->show_txt3 != 0} checked="true" {/if} />
				{l s='Como medir tu joya'}
			</span>

		</label>
		<div class="col-lg-9">
			{include
				file="controllers/products/textarea_lang.tpl"
				languages=$languages
				input_name='new_joyas'
				class="autoload_rte"
				input_value=$product->new_joyas
				max=$PS_PRODUCT_SHORT_DESC_LIMIT}
		</div>

	</div>

Luego en el product.tpl del theme, también esta todo creado.

<div class="container container-accordeon">
						            <div class="accordion">
						              	<dl>
						              		{if $product->show_txt == 0} <!-- SI EL VALOR ES 0 QUE NO MUESTRE NADA -->
						              		{else $product->show_txt == 1} <!-- SI EL VALOR ES 1 QUE MUESTRE EL CONTENIDO -->
							                <dt>
							                    <a href="#accordion1" aria-expanded="false" aria-controls="accordion1" class="accordion-title accordionTitle js-accordionTrigger">
							                  	Características Técnicas / Información adicional</a  >
							                </dt>
							                <dd class="accordion-content accordionItem is-collapsed" id="accordion1" aria-hidden="true">
							                    <p>{$product->new_carac}</p>
							                </dd>
							                {/if}

							                {if $product->show_txt1 == 0}
						              		{else $product->show_txt1 == 1}   
							                <dt>
							                    <a href="#accordion2" aria-expanded="false" aria-controls="accordion2" class="accordion-title accordionTitle js-accordionTrigger">
							                    Detalles del envío</a>
							                </dt>
							                <dd class="accordion-content accordionItem is-collapsed" id="accordion2" aria-hidden="true">
							                    <p>{$product->new_send}</p>
							                </dd>
							             	{/if}

							             	{if $product->show_txt2 == 0}
						              		{else $product->show_txt2 == 1}  
							             	<dt>
							                	<a href="#accordion3" aria-expanded="false" aria-controls="accordion3" class="accordion-title accordionTitle js-accordionTrigger">
							                    Consejo sobre el cuidado del producto
							                </a>
							             	</dt>
							                <dd class="accordion-content accordionItem is-collapsed" id="accordion3" aria-hidden="true">
							                <p>{$product->new_other}</p>
							                </dd>
							                {/if}

							                {if $product->show_txt3 == 0}
						              		{else $product->show_txt3 == 1}   
							                <dt>
							                	<a href="#accordion4" aria-expanded="false" aria-controls="accordion4" class="accordion-title accordionTitle js-accordionTrigger">
							                    Como medir tu joya
							                </a>
							             	</dt>
							                <dd class="accordion-content accordionItem is-collapsed" id="accordion4" aria-hidden="true">
							                <p>{$product->new_joyas}</p>
							                </dd>
							                {/if}
							                
						           		</dl>
						            </div>

Inclusive en la base de datos en ps_product-lang he creado para que se guarde el texto de los nuevo campos, lo único que me queda es ver como puedo hacer que se guarde el checkbox para mostrarlo u ocultarlo.

 

Gracias

Edited by angeldavo (see edit history)
Link to comment
Share on other sites

Nada, lo entendí mal, asi como lo has hecho no es necesario añadir nada en el ProductController.php. Para el checkbox seria el mismo proceso creando un campo en la tabla product del mismo tipo del active, como imagen adjunta y en la classe como el override que te puse en el mensaje de mas arriba

post-107989-0-44968600-1459497755_thumb.png

Link to comment
Share on other sites

Poco a poco va haciendo algo. Ahora me da el siguiente error... Los campos lo tengo creados en la tabla ps_product, los tengo que crear en ps_product_shop?

UPDATE `ps_product_shop` SET `id_product` = '604',`id_category_default` = '20',`id_tax_rules_group` = '1',`on_sale` = '0',`online_only` = '0',`ecotax` = '0',`minimal_quantity` = '1',`price` = '41.280992',`wholesale_price` = '0',`unity` = '',`unit_price_ratio` = '0',`additional_shipping_cost` = '0',`customizable` = '0',`text_fields` = '0',`uploadable_files` = '0',`active` = '1',`redirect_type` = '404',`id_product_redirected` = '0',`available_for_order` = '1',`available_date` = '0000-00-00',`condition` = 'new',`show_price` = '1',`indexed` = '0',`visibility` = 'both',`cache_default_attribute` = '1461',`advanced_stock_management` = '0',`date_add` = '2016-01-09 12:49:25',`date_upd` = '2016-04-01 13:53:43',`pack_stock_type` = '3',`show_txt` = '1',`show_txt1` = '1',`show_txt2` = '1',`show_txt3` = '1',`id_shop` = '1' WHERE id_product = 604 AND id_shop = 1

Edited by angeldavo (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...