I'm using a module for displaying grouped configurable products and all options are showing except custom options. They are displaying on the configurable product page but that's it. I'm trying to use the code in app\design\frontend\blank\blank\template\catalog\product\view\options.phtml in my custom configurable.phtml but $_options is showing up null. Here is the code used to retrieve $_options
<?php $_options = Mage::helper('core')->decorateArray($this->getOptions()) ?>
<?php if (count($_options)):?>
and after the javascript
<?php foreach($_options as $_option): ?>
<?php echo $this->getOptionHtml($_option) ?>
<?php endforeach; ?>
</dl>
<?php else: echo dlkghflghf;?>
<?php endif; ?>
The dlkghflghf is displaying so i know $_options is not showing up. Any suggestions?
Your custom configurable.phtml is a template of what block? You can use a block that extends Mage_Catalog_Block_Product_View_Options or you can set your own method for options like the method from Mage_Catalog_Block_Product_View_Options, you also need to have a method getProduct():
public function getOptions()
{
return $this->getProduct()->getOptions();
}
Related
We would like to create an override for the Joomla newsflash module which should be able to display the individual Joomla article tags on the frontend:
"tag 1, tag 2, tag 3 etc.."
RokSproket from rockettheme.com is able to achieve exactly that output. But we would like to have the same result with the newsflash module. We currently have the following code saved in our new _item.php override. There is no error message on the frontend but also no tags are visible. Any help is much appreciated.
<?php if ($params->get('show_tags', 1) && !empty($item->tags)) : ?>
<?php $item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $item->tagLayout->render($item->tags->itemTags); ?>
<?php endif; ?>
Here's how we've solved that question:
<?php
$itemtags = (new JHelperTags)->getItemTags('com_content.article', $item->id);
$taglayout = new JLayoutFile('joomla.content.tags');
$tags='';
if( !empty($itemtags) )
$tags = '<div class="itemtags">'.str_replace(',','',$taglayout->render($itemtags)).'</div>';
?>
<?php echo $tags; ?>
I needed to add a custom attribute to categories on Magento, I have been able to do so using:
http://www.atwix.com/magento/add-category-attribute/
But now, I will like to turn the custom attribute into a select box and load the options from a external database/module. Is there any way to specificy the options available for the custom attribute in order to make them dinamic?
Thanks.
Have you found the solution? I'm doing it in phtml file like this
<?php $categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*'); ?>
<?php foreach ($categories as $category): ?>
<?php $customAtt= $category->getCustom_att(); ?>
<?php print_r ($customAtt); ?>
<?php endforeach; ?>
That way will populate all your custom category attribute values. Change the getCustom_att() with your custom attribute.
To make it a select option list, read this https://magento.stackexchange.com/questions/8674/how-to-get-all-custom-category-attribute-values/8692#8692
I have a list of store categories, and everything is working well except for one thing. I would like the list of categories to omit any that are set as 'Include in Navivation Menu = No'.
I can tell at this point that this attribute is not being loaded, but I'm having a difficult time figuring out where to place the filter. Currently, I am getting my category list via:
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
Followed by:
<?php foreach ($_categories as $_category) : ?>
<?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
...
...
At this point, I have my category objects how I want them. But if I run a debug on these objects, the 'include_in_menu' attribute is not listed.
So for some reason:
<?php $_subCategory->getIncludeInMenu() ?>
Was not working for me after I ran:
<?php foreach($_parentCategory->getChildrenCategories() as $_subCategory) : ?>
The object was still the same model, but ['include_in_menu'] was no longer part of the object. I don't like this solution, but I just reconverted the object back:
<?php $_subCategory = Mage::getModel('catalog/category')->load($_subCategory->getId()) ?>
And then it worked fine. Not sure why getting the children would strip down the object, but it does.
I have few frontend modules which has own sidebar menu link. I want to create those links in actions class of module:
public function preExecute()
{
$items['plan/new'] = 'Create Plan';
$items['plan/index'] = 'Plans Listing';
$this->getResponse()->setSlot('sidebar', $items);
}
Slot file sidebar.php
#apps/frontend/templates/sidebar.php
<?php slot('sidebar') ?>
<ul>
<?php foreach($items as $url => $title) : ?>
<li><?php echo link_to($url, $title) ?></li>
<?php endforeach ?>
</ul>
<?php end_slot() ?>
layout.php:
<?php if (has_slot('sidebar')): ?>
<div id="sidebar"><?php include_slot('sidebar') ?></div>
<?php endif ?>
but my output is Array, how can I render my slot?
You seem to be mixing slots and partials. In your action, you set your slot to an array, later you call include_slot, and the string representation is Array, that is correct.
You should pass items via $this->items = $items, then in your action see if isset($items) is true, and call include_partial("sidebar", array("items" => $items)) if neccesary. This will look for a file called _sidebar.php.
For more detailed information of how this stuff works, read the Inside the View Layer: Code fragments part of the sf1.4 book.
I want to setup the category catalog pages in Magento such that the first page contains the category image and the first three products in that category. Then the following pages contain six products per page without the category image.
I can't figure out how this can be done.
Unfortunately I don't think you can do this without a lot of work. You'll need to rewrite the logic of the pagination, change the page size depending on which page it is, & offset the returned collection.
However you can easily only have the category image displayed on the first page.
This line returns the current page number:
Mage::getBlockSingleton('page/html_pager')->getCurrentPage();
So in template/catalog/category/view.phtml you can just do a conditional around the category image display, find the section:
<?php if($_imgUrl): ?>
<?php echo $_imgHtml ?>
<?php endif; ?>
and replace it with:
<?php if($_imgUrl): ?>
<?php if(Mage::getBlockSingleton('page/html_pager')->getCurrentPage()==1):?>
<?php echo $_imgHtml ?>
<?php endif; ?>
<?php endif; ?>