Magento Newsletter Signup Source - magento

I'm currently integrating Mailchimp with Magento, using Ebizmarts MageMonkey module, for an e-commerce store. The data I need to send to Mailchimp is first & last name, email, and signup source/location e.g header, footer, checkout, etc...I have successfully been able to get first name, last name, and email, but cannot figure out how to get signup source/location.
I've done a lot of research for a way to get the signup source/location when a user opts in to our newsletter. I haven't be successful in finding anything other than how to move the newsletter block to a different location on the page.
So my question is, When a customer or guest signs up for our newsletter is there a way to get the location where they signed up, e.g header, footer, checkout, etc...
Any help is greatly appreciated. Thanks.

The newsletter signup template is in:
app/design/frontend/base/default/customer/form/register.phtml
Specifically it's the following lines:
<li class="control">
<div class="input-box">
<input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign up for Newsletter') ?>" value="1" id="is_subscribed"<?php if($this->getFormData()->getIsSubscribed()): ?> checked="checked"<?php endif; ?> class="checkbox" />
</div>
<label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
<?php /* Extensions placeholder */ ?>
<?php echo $this->getChildHtml('customer.form.register.newsletter')?>
</li>
Additionally the layout for this page can be found in:
customer.xml
Under the layout handle:
<customer_account_create translate="label">
The lines that define this block:
<block type="customer/form_register" name="customer_form_register" template="customer/form/register.phtml">
<block type="page/html_wrapper" name="customer.form.register.fields.before" as="form_fields_before" translate="label">
<label>Form Fields Before</label>
</block>

Related

how do I alter a link in the my account navigation column in magento?

im trying to alter the navigation links in the my account section of my magento site currently they look like this:
I turned on debug template paths so I can locate where it came from but it just sent me to navigation.phtml, which was just some php code the echos the links in a list form see below.
<div class="block block-account">
<div class="block-title">
<strong><span><?php echo $this->__('My Account'); ?></span></strong>
</div>
<div class="block-content">
<ul>
<?php $_links = $this->getLinks(); ?>
<?php $_index = 1; ?>
<?php $_count = count($_links); ?>
<?php foreach ($_links as $_link): ?>
<?php $_last = ($_index++ >= $_count); ?>
<?php if ($this->isActive($_link)): ?>
<li class="current<?php echo ($_last ? ' last' : '') ?>"><strong><?php echo $_link->getLabel() ?></strong></li>
<?php else: ?>
<li<?php echo ($_last ? ' class="last"' : '') ?>><?php echo $_link->getLabel() ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
My goal is simple to rename "My Wishlist" to "My Sample Request" any ideas on how to achieve this ?
If renaming is only the issue than it is very simple.
You just edit the name in the "app/design/frontend/base/default/layout/wishlist.xml".
you will search for below code.
<customer_account>
<!-- Mage_Wishlist -->
<reference name="customer_account_navigation">
<action method="addLink" translate="label" module="wishlist" ifconfig="wishlist/general/active"><name>wishlist</name><path>wishlist/</path><label>My Wishlist</label></action>
</reference>
</customer_account>
change the label "My Wishlist" to "My Sample Request".
This will work.But its not the best way to achieve this.First Override the "wishlist.xml" to your theme and then only make a change.
Hope this will help.
you dont need to do this from xml file , just open the
`app/locale/en_US/Mage_XmlConnect.csv
and around line 601 you wil see a "My Wishlist","My Wishlist"
you can change from there. if you will change in xml file than in multilangual site it will same for all languages. So change from translate file.
thanks
$this->getLinks() is heart of that template. It retrieves all links as an array and then loop through it and display each item. So the array returned by that code is actually constituted by another method addLink(). It normally use in layout files. My guess is, you need to alter that name in layout file.
File : app\design\frontend\<package>\<theme>\layout\customer.xml
You can see many code like this
<action method="addLink" translate="label" module="customer">
<name>account</name>
<path>customer/account/</path>
<label>Account Dashboard</label>
</action>
Here label is the part that you need to change.
So check for this code in customer.xml file. Find the code that generate "Wisthlist" link. Then change the label part according to your need

How do I get the rating summary in new products section on my homepage?

On my homepage I have “New products” section. I created it with the following code:
<block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage2" template="catalog/product/new.phtml">
<action method="setColumnCount"><columns>3</columns></action>
<action method="setProductsCount"><count>3</count></action>
</block>
That works fine, but I want also show the rating summary (stars and amount of reviews) om my homepage:
<?php if($_product->getRatingSummary()): ?>
<div class="ratingsum">
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
</div>
The code above gives nothing back. It seems that there are no reviews, but I definitely know that there are reviews!
The problem seems the block type, for new products: catalog/product_new and for bestsellers bestsellers/list, is that possible?
I have also a “best sellers” section on my homepage. There is getting the rating summary no problem.
Also:
$_productCollection=$this->getLoadedProductCollection();
Doesn't work in my new.phtml. It returns no collection/products.
Below is the code to retrieve product rating summary.
$storeId = Mage::app()->getStore()->getId();
$summaryData = Mage::getModel('review/review_summary')
->setStoreId($storeId)
->load('product_id');
if($summaryData->getRatingSummary()){
?>
<div class="rating-box" style="float:left;">
<div class="rating" style="width: <?php echo $summaryData->getRatingSummary().'%'; ?>"></div>
</div>
<?php
}
Just be sure to pass it the right product id number.

I want add custom column for sidebar all page in Magento

I want add my custom sidebar next right column all page.
Please check this link: http://www.wildbuilder.com/images/Untitled-1-Recovered.png
(I explain using image.)
There are featured products in the mini sidebar.
I don't want include the mini sidebar into right column. next to right column :)
I already made featured-products.phtml at /catalog/product/ folder.
And I created cms block, featured_products and I put in this code
{{block type="catalog/product_list" category_id="4" template="catalog/product/featured-products.phtml"}}
And I added code at page.xml like this.
<block type="core/text_list" name="content" as="content" translate="label">
<label>Main Content Area</label>
<block type="cms/block" name="featured_products">
<action method="setBlockId"><block_id>featured_products</block_id></action>
</block>
</block>
Then I added code in 2columns-right.phtml at /template/page/ folde.
like this,
<div class="wrapper">
<?php echo $this->getChildHtml('global_notices') ?>
<div class="page">
<?php echo $this->getChildHtml('header') ?>
<div class="main-container col2-right-layout">
<?php echo $this->getChildHtml('breadcrumbs') ?>
<div class="main">
<div class="col-main">
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('content') ?>
</div>
<div class="col-right sidebar"><?php echo $this->getChildHtml('right') ?></div>
</div>
</div>
<?php echo $this->getChildHtml('before_body_end') ?>
</div>
<?php //my slidebar ?>
<div style="float:right;width:92px;vertical-align:top;background-color:#000;margin:-766px 110px 0 0;">
<?php echo $this->getChildHtml('featured_products') ?>
</div>
But my sidebar is not showing.
How Can I Do???
Please let me know.
Thank you.
Also, try the following in 2-columns-right.phtml
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId(featured_products)->toHtml() ?>
No no no. Never edit the 2col-right, left or any other ./page/ template file for a modification such as this. You should also not be making changes in page.xml
What you need to do is understand layout handles on Magento. As your change relates specifically to catalogue, you should edit
catalog.xml
Then within that file, you can utilise the layout handle - which means, it appears, by default, everywhere.
<default>
<reference name="right">
<block type="catalog/product_list" template="catalog/product/featured-products.phtml" name="featuredprods" before="-">
<action method="setCategoryId"><category_id>4</category_id></action>
</block>
</reference>
</default>
There is no need for a phtml modification, or a CMS block or an edit of page.xml

Custom blocks not being rendered

I have developed a collections module for a clients Magento site. Among other things, this module pulls in product details (media, description, attributes) on the category listing page. The issue I am running into is that my blocks are not rendering on the clients site (Magento EE 1.8), even though everything works locally (Magento CE 1.6).
Developer mode has been activated, but I see no errors on the page, and I know that Magento is seeing the module as it correctly shows up in the admin under System > Configuration > Advanced.
We set the base block class name in app/code/local/Mycompany/Collections/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_Collections>
<version>0.1.0</version>
</Mycompany_Collections>
</modules>
<global>
<blocks>
<mycompany_collections>
<class>Mycompany_Collections_Block</class>
</mycompany_collections>
</blocks>
</global>
</config>
We insert our blocks to the layout in app/design/frontend/enterprise/mytheme/layout/local.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<catalog_category_view>
<reference name="product_list">
<block type="mycompany_collections/collection" name="collection" template="collections/collection.phtml">
<block type="mycompany_collections/product" name="add-to-cart" template="collections/product/add-to-cart.phtml" />
<block type="mycompany_collections/product" name="description" template="catalog/product/view/description.phtml" />
<block type="mycompany_collections/product_attributes" name="attributes" template="catalog/product/view/attributes.phtml" />
<block type="mycompany_collections/product_media" name="media" template="catalog/product/view/media.phtml" />
</block>
</reference>
</catalog_category_view>
</layout>
The mycompany_collections/collection block extends Mage_Catalog_Block_Product_List and reloads the products to ensure we have fetched all the relevant data from the database.
class Mycompany_Collections_Block_Collection extends Mage_Catalog_Block_Product_List {
public function reloadProducts() {
// Fully reload each of the products in this category so that we have
// all the information required to display product details.
// TODO: find a more efficient way to grab all the info for all the
// products, as this would seem to add 1 (or more) additional
// query per product.
$reloaded = array();
foreach($this->getParentBlock()->getLoadedProductCollection() as $product){
$reloaded[] = Mage::getModel('catalog/product')->load($product->getId());
}
return $reloaded;
}
}
The mycompany_collections/product block extends Mage_Catalog_Block_Product_Abstract with custom methods to allow us to explicitly set the product on the block and return that product without pulling from the registry.
class Mycompany_Collections_Block_Product extends Mage_Catalog_Block_Product_Abstract {
private $_product = null;
public function _prepareLayout() {
// We don't need to do anything here.
}
// NOTE: Must be called before ->toHtml()
public function setProduct($product) {
$this->_product = $product;
return $this;
}
public function getProduct() {
return $this->_product;
}
}
Both the mycompany_collections/product_attributes and mycompany_collections/product_media blocks do the same get/set_product overrides for their equivalent abstract parent classes.
Inside our collection.phtml template, we call $this->reloadProducts() and iterate over the product list to display the product details and buy collection popups (these are js lightboxes that activate on click)
<?php
$_productCollection = $this->reloadProducts();
?>
<!-- Buy collection popup -->
<div id="buy-collection" class="no-display">
<h1>Buy Collection</h1>
<?php foreach($_productCollection as $_product): ?>
<div id="buy-collection-product-<?php echo $_product->getId(); ?>" class="product">
<div class="media"><?php echo $this->getChild('media')->setProduct($_product)->toHtml(); ?></div>
<?php /*
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(100); ?>" width="100" height="100" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
*/ ?>
<a href="<?php echo $_product->getProductUrl() ?>" ><?php echo $_product->getName(); ?></a>
<?php if($_product->isSaleable()): ?>
<div class="add-to-cart"><?php echo $this->getChild('add-to-cart')->setProduct($_product)->toHtml(); ?></div>
<?php else: ?>
<div class="out-of-stock"><?php echo $this->__('Out of stock') ?></div>
<?php endif; ?>
<div class="details">
<div class="description">
<?php echo $this->getChild('description')->setProduct($_product)->toHtml(); ?>
</div>
<div class="attributes">
<?php echo $this->getChild('attributes')->setProduct($_product)->toHtml(); ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<!-- Product detail popups -->
<div id="product-details" class="no-display">
<?php foreach ($_productCollection as $_product): ?>
<div id="product-detail-<?php echo $_product->getId(); ?>" class="product">
<div class="media"><?php echo $this->getChild('media')->setProduct($_product)->toHtml(); ?></div>
<div class="description"><?php echo $this->getChild('description')->setProduct($_product)->toHtml(); ?></div>
<div class="attributes"><?php echo $this->getChild('attributes')->setProduct($_product)->toHtml(); ?></div>
</div>
<?php endforeach; ?>
</div>
To actually fire all this off, for any product category that we wish to display as collection we override the category.listing and product_list templates in the Custom Design tab of that category in the admin. These templates contain design changes, and product/list.phtml calls the collection block.
<reference name="product_list">
<action method="setTemplate">
<template>catalog/collections/product/list.phtml</template>
</action>
</reference>
<reference name="category.products">
<action method="setTemplate">
<template>catalog/collections/category/view.phtml</template>
</action>
</reference>
Inside product/list.phtml we call the collection block with a simple echo $this->getChildHtml('collection');. Nothing is returned on this line. No template, no PHP errors, nothing. As mentioned above, this all works beautifully in my local dev environment.
That's the overview of how things are setup. Here's what I have done to debug:
Using Alan Storm's Layoutviewer module, I have confirmed that my blocks are listed on ?showLayout=page, and the handle "catalog_category_view" is listed in ?showLayout=handles. However, when I print $this->getSortedChildren() in product/list.phtml the collection block is not listed.
If I replace the collection block in layout.xml with a super simple core/text block, it does render.
<?xml version="1.0"?>
<layout version="0.1.0">
<catalog_category_view>
<reference name="product_list">
<block type="core/text" name="collection"><action method="setText"><text>This is a test</text></action></block>
</reference>
</catalog_category_view>
</layout>
This led me to believe the problem was deeper in my own code, so I simplified and went totally basic… I removed the reloadProducts method from Mycompany_Collections_Block_Collection and reduced collections.phtml to a single line of text to see if something in the template or child blocks were causing an issue. Unfortunately this had no affect and I still got no output.
I'm really at a loss as to why this is not working. I first thought it may be a difference between the Enterprise and Community editions, but something as fundamental as the layout/block system is unlikely to differ between them. There clearly seems to be something missing, and I'm hoping someone may be able to point in the right direction.
Thanks!
Did you check Mycompany_Collections.xml available in /app/etc/modules section and codepool enabled?
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_Collections>
<active>true</active>
<codePool>local</codePool>
</Mycompany_Collections>
</modules>
</config>

How to hide/remove search field in Magento

The store is running in: Magento ver. 1.4.1.1
Because the search is not working, we're wanting to hide the search bar until I have time to look into the problem. I've searched everywhere. I keep seeing people editing catalogsearch.xml but I don't even know where to find that.
To me it looks like the search field is contained in a content block (under or above the left navvy) which also has contact information. But I don't even know where that content block is.
==== EDIT ====
(Since I can't answer my OWN post for another 5 hours, here's the answer below:)
Found it:
Location: app > design > frontend > default > calshrm > template > catalogsearch > form.mini.phtml
Just removed the code and stored the removed section as a .txt file in the same directory.
Code removed:
<form id="search_mini_form" action="<?php echo $this->helper('catalogsearch')->getResultUrl() ?>" method="get">
<div class="dfsboxleft">
<label for="search"><!--?php echo $this->__('Search:') ?--></label>
<button type="submit" title="<?php echo $this->__('Search') ?>" class="dfsbutton">
<span>
<span><!--?php echo $this->__('Search') ?--></span>
</span>
</button>
</div>
<div class="dfsbox">
<input id="search" type="text" name="<?php echo $this->helper('catalogsearch')->getQueryParamName() ?>"
value="<?php echo $this->helper('catalogsearch')->getEscapedQueryText() ?>" class="dfsinput" />
<div id="search_autocomplete" class="search-autocomplete"></div>
<script type="text/javascript">
//<![CDATA[
var searchForm = new Varien.searchForm('search_mini_form', 'search', '<?php echo $this->__('Product Search') ?>');
searchForm.initAutocomplete('<?php echo $this->helper('catalogsearch')->getSuggestUrl() ?>', 'search_autocomplete');
//]]>
</script>
</div>
</form>
I'm assuming form.mini is something different than what is normal, in which case you may have to look for the file mentioned above, which I'm not sure where that one is.
Go to app/design/frontend/[your interface]/[your theme]/template/page/html/header.phtml and remove:
getChildHtml('topSearch') ?>
You can also disable the module in System->Configuration->Advanced->Disable Modules Output :: Mage_CatalogSearch.
You can hide the search with the layout xml. You can use local.xml in
app/design/frontend/yourpackage/default/layout/local.xml
Put this in to hide the search:
<layout>
<default>
<reference name="header">
<remove name="top.search" />
</reference>
</default> </layout>
With the local.xml file you have a central point in your theme to change the layout.
I'm using chrome (right clicking on the serch box, and clicking inspect element) to look at the code. You could hide the input id "search" with a name "q" using jquery. It should be more simple than finding the blocks in xml.
It's not really the best solution, since refreshing the page may show it for a second (depending on the speed of the site), but it should be temporary and you're better off spending the time fixing the search IMO.

Resources