magento-Assign Custom attribute value (from drop down) programatically - magento

I have to assign custom attributes from drop down menu. means we have lots of books and i create custom attribute for languages like English,Hindi,Punjabi etc. i have tried this
$product_id = Mage::getModel('catalog/product')->load(23340);
echo "Product Name".$product_id->getName();
$product_id->setStoreId(1)->setData(('book_lang'),24)->save();
where 24 is the id of my custom drop down attribute (for English) it works but it not shown in filter attributes.
any response is precious...

hi for custom option check magento admin section and
in catalog.xml see this
<block type="core/template_facade" name="product.info.container1" as="container1">
<action method="setDataByKey">
<key>alias_in_layout</key>
<value>container1</value>
</action>
<action method="setDataByKeyFromRegistry">
<key>options_container</key>
<key_in_registry>product</key_in_registry>
</action>
<action method="append">
<block>product.info.options.wrapper</block>
</action>
<action method="append">
<block>product.info.options.wrapper.bottom</block>
</action>
</block>
<block type="core/template_facade" name="product.info.container2" as="container2">
<action method="setDataByKey">
<key>alias_in_layout</key>
<value>container2</value>
</action>
<action method="setDataByKeyFromRegistry">
<key>options_container</key>
<key_in_registry>product</key_in_registry>
</action>
<action method="append">
<block>product.info.options.wrapper</block>
</action>
<!-- <action method="append"><block>product.info.options.wrapper.bottom</block></action>-->
</block>
and check the product view.phtml for $this->getChildChildHtml('container2', '', true, true) please provide me some more information may be i will suggest you proper
and for filter try this $productCollection->addAttributeToFilter('costume_attribute_name', $productId);

Related

magento duplicate block twice in page sales order view

I have an installation of magento 1.9.2.1, I have a duplicate block rendering in some pages this is the code used in my custom theme sales.xml:
<sales_order_view translate="label">
<label>Customer My Account Order View</label>
<update handle="customer_account"/>
<reference name="my.account.wrapper">
<block type="sales/order_info" as="info" name="sales.order.info">
<block type="sales/order_info_buttons" as="buttons" name="sales.order.info.buttons" />
</block>
<block type="sales/order_view" name="sales.order.view">
<block type="sales/order_items" name="order_items" template="sales/order/items.phtml">
<action method="addItemRender"><type>default</type><block>sales/order_item_renderer_default</block><template>sales/order/items/renderer/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>sales/order_item_renderer_grouped</block><template>sales/order/items/renderer/default.phtml</template></action>
<block type="sales/order_totals" name="order_totals" template="sales/order/totals.phtml">
<action method="setLabelProperties"><value>colspan="2" class="a-right"</value></action>
<action method="setValueProperties"><value>class="last a-right"</value></action>
<block type="tax/sales_order_tax" name="tax" template="tax/order/tax.phtml" />
</block>
</block>
</block>
</reference>
<reference name="sales.order.info">
<action method="addLink" translate="label" module="sales"><name>view</name><path></path><label>Order Information</label></action>
<action method="addLink" translate="label" module="sales"><name>invoice</name><path>*/*/invoice</path><label>Invoices</label></action>
<action method="addLink" translate="label" module="sales"><name>shipment</name><path>*/*/shipment</path><label>Shipments</label></action>
<action method="addLink" translate="label" module="sales"><name>creditmemo</name><path>*/*/creditmemo</path><label>Refunds</label></action>
</reference>
<block type="core/text_list" name="additional.product.info" translate="label">
<label>Additional Product Info</label>
</block>
</sales_order_view>
If anybody has an idea about the origin of this thank you for help.

Custom page breadcrumb name in magento

I'm trying to change the breadcrumb that is showed on my blog page.
Now I have something like" Home / Blog ", but I want it to show like " Home / NewNameHere ".
I went to my blog.xml file and where I had this:
<blog_index_index>
<reference name="content">
<block type="blog/blog" name="blog" template="blog/blog.phtml"/>
</reference>
</blog_index_index>
Changed to this:
<blog_index_index>
<reference name="content">
<block type="blog/blog" name="blog" template="blog/blog.phtml"/>
<action method="addCrumb">
<name>newnamehere</name>
<params>
<label>newnamehere</label>
<title>newnamehere</title>
<link> /blog/</link>
</params>
</action>
</reference>
</blog_index_index>
But nothing has changed. Any help would be appreciated.
Try the below code:
<blog_index_index>
<reference name="content">
<block type="blog/blog" name="blog" template="blog/blog.phtml"/>
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs">
<action method="addCrumb">
<name>NewName</name>
<params>
<label>NewName</label>
<title>NewName</title>
<link>/blog/</link>
</params>
</action>
</block>
</reference>
</blog_index_index>
And in your blog.phtml call like this
<?php echo $this->getLayout()->getBlock('breadcrumbs')->toHtml();?>

getChild method in a module doesn't seem to refer to a child(?)

I am using the Meanbee Infinite Scroll module in my project. I have it working for normal category product listings. But now I'm attempting to have it activate on my custom made module.
However I am stumped over line 68 in Script.php:
66 return (
67 $block !== false &&
68 $block->getChild('toolbar') !== false && // <-- This line
69 $this->_getPagerBlock() !== false &&
70 $this->_getPagerBlock()->getCollection()
71 );
There is no xml element that has attribute name of toolbar. Even in the normal category xml that is working. So what is "toolbar" refering to?
A var_dump($block->getChild('toolbar')); returns false on my page but not on the normal category product listing page.
My XML is as follows (for clarity):
<block type="mynamespace/mymodule" name="mymodule.view" template="mynamespace/mymodule/view.phtml">
<block type="catalog/product_list" name="product_list" template="toxicfox/giftfinder/list.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</block>
And the core XML (which works with the Infinite Scroll module) is:
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</block>
As you can see, neither block of XML has any element with an attribute name of "toolbar". The only difference is line 1.
Any help is appreciated.
In the Mage_Catalog_Block_Product_List::_beforeToHtml() method, the toolbar block is retrieved from the layout with the name that was indicated by the setToolbarBlockName action, then set as a child block of the products list with the toolbar alias.
In your case, the problem may be that the $block hasn't been output yet with toHtml(), so that it doesn't know yet about its toolbar child, or something of this kind (hard to say because the extension is commercial).

Magento EE 1.11 - Customer Attributes Not Visible

Our client wants to add an 'Industry' dropdown to customer registration. We have created a new customer attribute, 'industry' and entered in the appropriate values.
It was not showing on the front-end. I looked into customer/form/register.phtml and it wasn't calling anything for attributes, so I pulled from enterprise/default/template/customer/form/register.phtml the following:
<?php $customerAttributes = $this->getChild('customer_form_user_attributes');?>
<?php if ($customerAttributes): ?>
<?php $customerAttributes->setShowContainer(false);?>
<?php $this->restoreSessionData($customerAttributes->getForm());?>
<?php echo $customerAttributes->toHtml()?>
<?php endif;?>
And then I added in the .xml update found in 'enterprise/layout/customer.xml':
<remove name="right"/>
<remove name="left"/>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<block type="page/html_wrapper" name="customer.form.register.fields.before" translate="label">
<label>Form Fields Before</label>
<!--action method="setMayBeInvisible"><value>1</value></action-->
<action method="setElementClass"><value>rewards</value></action>
</block>
<block type="enterprise_customer/form" template="customer/form/userattributes.phtml" name="customer_form_user_attributes">
<action method="setFormCode"><code>customer_account_create</code></action>
<action method="setEntityModelClass"><code>customer/customer</code></action>
</block>
<block type="enterprise_customer/form" template="customer/form/userattributes.phtml" name="customer_form_address_user_attributes">
<action method="setFormCode"><code>customer_register_address</code></action>
<action method="setEntityModelClass"><code>customer/address</code></action>
</block>
<reference name="content">
<block type="customer/form_register" name="customer_form_register" template="customer/form/register.phtml">
<action method="append"><block>customer.form.register.fields.before</block> <alias>form_fields_before</alias></action>
<action method="append"><block>customer_form_user_attributes</block> </action>
<action method="append"> <block>customer_form_address_user_attributes</block></action>
</block>
</reference>
<update handle="customer_form_template_handle"/>
At this point, the attributes are not visible on the front-end. If I perform:
<pre>
<?php print_r($customerAttributes->getUserDefinedAttributes()) ?>
</pre>
I am returned the array of attributes as I would expect. What am I missing here?
Found it. Needed this stuff in customer.xml. For some reason using the enterprise/default customer.xml wasn't working, but I added this in and it was good.
<customer_form_template_handle>
<reference name="content">
<block name="customer_form_template" type="enterprise_customer/form_template">
<action method="addRenderer">
<type>text</type>
<renderer_block>enterprise_customer/form_renderer_text</renderer_block>
<template>customer/form/renderer/text.phtml</template>
</action>
<action method="addRenderer">
<type>textarea</type>
<renderer_block>enterprise_customer/form_renderer_textarea</renderer_block>
<template>customer/form/renderer/textarea.phtml</template>
</action>
<action method="addRenderer">
<type>multiline</type>
<renderer_block>enterprise_customer/form_renderer_multiline</renderer_block>
<template>customer/form/renderer/multiline.phtml</template>
</action>
<action method="addRenderer">
<type>date</type>
<renderer_block>enterprise_customer/form_renderer_date</renderer_block>
<template>customer/form/renderer/date.phtml</template>
</action>
<action method="addRenderer">
<type>select</type>
<renderer_block>enterprise_customer/form_renderer_select</renderer_block>
<template>customer/form/renderer/select.phtml</template>
</action>
<action method="addRenderer">
<type>multiselect</type>
<renderer_block>enterprise_customer/form_renderer_multiselect</renderer_block>
<template>customer/form/renderer/multiselect.phtml</template>
</action>
<action method="addRenderer">
<type>boolean</type>
<renderer_block>enterprise_customer/form_renderer_boolean</renderer_block>
<template>customer/form/renderer/boolean.phtml</template>
</action>
<action method="addRenderer">
<type>file</type>
<renderer_block>enterprise_customer/form_renderer_file</renderer_block>
<template>customer/form/renderer/file.phtml</template>
</action>
<action method="addRenderer">
<type>image</type>
<renderer_block>enterprise_customer/form_renderer_image</renderer_block>
<template>customer/form/renderer/image.phtml</template>
</action>
</block>
</reference>
</customer_form_template_handle>
You should check template/customer/form/userattributes.phtml which is controlling user defined attributes. I don't know, does anybody touched this file? Check this first.
<?php foreach ($this->getUserDefinedAttributes() as $attribute):?>
<?php $attributeContent = $this->getAttributeHtml($attribute);?>
<?php if ($attributeContent): ?>
<li><?php echo $attributeContent;?></li>
<?php endif;?>
<?php endforeach;?>

Magento - Add CMS Block to One Page

I have this code in a xml layout file:
<reference name="left">
<block type="blog/blog" name="left.blog.menu" before="-">
<action method="setTemplate" ifconfig="blog/menu/left">
<template>aw_blog/menu.phtml</template>
</action>
<block type="blog/tags" name="blog_tags" />
</block>
</reference>
I want to add a cms static block to the blog pages using this code:
<block type="cms/block" name="brand_list">
<action method="setBlockId"><block_id>brand_list</block_id></action>
</block>
If I add it in directly after this line:
<reference name="left">
It works but it is then displayed on every page. How can I get it to show only on the blog pages?
Thanks.
Edit: Here is the entire xml file:
<layout version="0.1.0">
<default>
<reference name="footer_links">
<block type="blog/blog" name="add.blog.footer">
<block type="blog/tags" name="blog_tags" />
<action method="addFooterLink" ifconfig="blog/menu/footer"></action>
</block>
</reference>
<reference name="right">
<block type="blog/blog" name="right.blog.menu" before="-">
<action method="setTemplate" ifconfig="blog/menu/right" ifvalue="1">
<template>aw_blog/menu.phtml</template>
</action>
<block type="blog/tags" name="blog_tags" />
</block>
</reference>
<reference name="left">
<block type="blog/blog" name="left.blog.menu" before="-">
<action method="setTemplate" ifconfig="blog/menu/left">
<template>aw_blog/menu.phtml</template>
</action>
<block type="blog/tags" name="blog_tags" />
</block>
</reference>
<reference name="top.links">
<block type="blog/blog" name="add.blog.link">
<action method="addTopLink" ifconfig="blog/menu/top"></action>
<block type="blog/tags" name="blog_tags" />
</block>
</reference>
<reference name="head">
<action method="addItem"><type>skin_css</type><name>aw_blog/css/style.css</name></action>
</reference>
</default>
<blog_index_index>
<reference name="content">
<block type="blog/blog" name="blog" template="aw_blog/blog.phtml"/>
</reference>
</blog_index_index>
<blog_index_list>
<reference name="content">
<block type="blog/blog" name="blog" template="aw_blog/blog.phtml"/>
</reference>
</blog_index_list>
<blog_post_view>
<reference name="content">
<block type="blog/post" name="post" template="aw_blog/post.phtml">
<block type="socialbookmarking/bookmarks" name="bookmarks" template="bookmarks/bookmarks.phtml"/>
</block>
</reference>
</blog_post_view>
<blog_cat_view>
<reference name="content">
<block type="blog/cat" name="cat" template="aw_blog/cat.phtml" />
</reference>
</blog_cat_view>
<blog_rss_index>
<block type="blog/rss" output="toHtml" name="rss.blog.new"/>
</blog_rss_index>
</layout>
if it's going inside a section then it will be applied to all pages, you want to put the and its contents inside the sections (there'll be the listing page and individual post pages - the sections should already exist in the aw_blog.xml file
It appears on all pages, because you probably put the code in the section of the layout xml. Just put into a section named after the route where it should appear.
So try:
<blog>
<reference name="left">
<block type="cms/block" name="brand_list">
<action method="setBlockId"><block_id>brand_list</block_id></action>
</block>
</reference>
</blog>
Change XML inside folder theme/layout for example page.xml add something like this to header:
<block type="page/html_header" name="header" as="header">
<!-- ... some origin code ... -->
<block type="page/html" name="custom_block" as="flashHeader" template="customer/custom_header.phtml"/>
</block>
Create file customer/custom_header.phtml with your custom html code.
Inside template page/html/header.phtml you can add something like this:
$dataCurrentPage = $this->getHelper('cms/page')->getPage()->getData();
$page_id = (isset($dataCurrentPage['identifier'])) ? $dataCurrentPage['identifier'] : null;
if ($page_id == 'home' ) { echo this->getChildHtml('flashHeader') }
Flash banner will be show only on homepage.
You can definitely use the custom layout update to place your own static block on left without any coding.
You need to create a static block and then put its reference into custom layout update
<reference name="left">
<block type="cms/block" name="my_left_block" before="-">
<action method="setBlockId"><block_id>my_left_block</block_id></action>
</block>
to view an example follow the link below
https://lampjs.wordpress.com/2015/07/06/magento-add-static-cms-block-to-category-page-on-left/

Resources