Agregar categoría en la página de inicio Muestra solo 1 producto
-
12-12-2019 - |
Pregunta
He investigado sobre este tema sobre Magento 1.9 sin agregar la categoría a la página de inicio.Entonces, terminé agregando:
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="15" template="catalog/product/list.phtml"}}
al contenido de la página de inicio.También aparece en la página de inicio, pero: solo con 1 producto de 5. ¿Por qué es eso y se puede cambiar?
Todavía soy muy nuevo en Magento y no he cambiado nada a la broca de diseño. He visto esta publicación: mismo problema , pero nadie ha respondido(Y no puedo comentarlo), he seguido Estos pasos , pero todo no funcionó.
Solución
¿Está utilizando el tema RWD de Magento 1.9?Si es así, el problema podría estar en el archivo de plantilla de catálogo / producto / list.phtml.
en catálogo / producto / list.phtml desde el tema RWD el siguiente código
de la línea 133 a 140
<?php
$_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();
foreach($_nameAfterChildren as $_nameAfterChildName):
$_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);
$_nameAfterChild->setProduct($_product);
?>
<?php echo $_nameAfterChild->toHtml(); ?>
<?php endforeach; ?>
y de la línea 178 a 186
<?php
//set product collection on after blocks
$_afterChildren = $this->getChild('after')->getSortedChildren();
foreach($_afterChildren as $_afterChildName):
$_afterChild = $this->getChild('after')->getChild($_afterChildName);
$_afterChild->setProductCollection($_productCollection);
?>
<?php echo $_afterChild->toHtml(); ?>
<?php endforeach; ?>
causará errores si agrega el bloque en el diseño sin los niños los bloques 'Name.Fter' y 'después'.
Si desea que esto trabaje en su página de inicio, debe crear una nueva plantilla en el tema, por ejemplo, catálogo / producto / list_home.phtml, y copie el código del catálogo / producto / list.phtml, pero elimine el código deLas líneas que indicaba.Luego, debe usar la nueva plantilla en el bloque de la página de inicio:
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="15" template="catalog/product/list_home.phtml"}}
Otros consejos
Eliminar esas líneas de catalog/product/list.phtml
<?php
//set product collection on after blocks
$_afterChildren = $this->getChild('after')->getSortedChildren();
foreach($_afterChildren as $_afterChildName):
$_afterChild = $this->getChild('after')->getChild($_afterChildName);
$_afterChild->setProductCollection($_productCollection);
?>
<?php echo $_afterChild->toHtml(); ?>
<?php endforeach; ?>