I've got a problem with a translation. I don't understand why my content is well translated in the website but not in the email. The translation is done in csv files, but when I call the sentence, as usual, Magento got the english translation instead of the french one.
email/stock.phtml :
<?php if ($products = $this->getProducts()): ?>
<p><?php echo $this->__('You are receiving this notification because you subscribed to receive alerts when the following products are back in stock:') ?></p>
<table>
<?php foreach ($products as $product): ?>
<tr>
<td><img src="<?php echo $this->helper('catalog/image')->init($product, 'thumbnail')->resize(75, 75) ?>" border="0" align="left" height="75" width="75" alt="<?php echo $this->escapeHtml($product->getName()) ?>" /></td>
<td>
<p><strong><?php echo $this->escapeHtml($product->getName()) ?></strong></p>
<?php $shortDescription = $this->_getFilteredProductShortDescription($product) ?>
<?php if ($shortDescription): ?>
<p><small><?php echo $shortDescription ?></small></p>
<?php endif; ?>
<p><?php if ($product->getPrice() != $product->getFinalPrice()): ?>
<?php echo $this->__('Regular Price:') ?> <strong style="text-decoration:line-through;"><?php echo Mage::helper('core')->currency($product->getPrice()) ?></strong><br />
<strong><?php echo $this->__('Special price:') ?> <span style="color:#FF0000;"><?php echo Mage::helper('core')->currency($product->getFinalPrice()) ?></span></strong>
<?php else: ?>
<strong><?php echo $this->__('Price:') ?></strong> <?php echo Mage::helper('core')->currency($product->getPrice()) ?>
<?php endif; ?></p>
<p><small><?php echo $this->__('Click here not to receive alerts for this product') ?></small></p>
</td>
</tr>
<?php endforeach; ?>
</table>
<p><?php echo $this->__('Unsubscribe from all stock alerts') ?></p>
<?php endif; ?>
Do you know how to say to Magento that it has to take the french translation in my email template ?
To translate an email, you can copy it from the en_US folder to a corresponding language folder (es_ES, for example), then perform the translation. When you do this, you can also add or remove other vars from the email. Most emails will have headers that show you what vars are available.
As for adding a country code to the telephone number, you will need to define a new block in a module that will do this for you.
There is also another solution on link
First of possibility: https://magento.stackexchange.com/questions/25612/cron-job-template-block-not-being-translated-but-testobserver-is
Second possibility:
Function that's responsible for sending product out of stock alert is called send and exists in file around line 229:
app/code/core/Mage/ProductAlert/Model/Email.php
The function's using below code to get customer's store:
$store = Mage::getModel('core/store')->load($this->_customer->getStoreId());
Function getStoreId on customer gets data from field "Created from - account[created_in]"
So if customer was created by an Admin from backend - the customer will always get default store (admin's) settings for language, currency, translations, etc.
Check what is returned for the customer that get's wrong translation and/or url's by this code:
<?php if(Mage::getSingleton('customer/session')->isLoggedIn()) {
$customerData = Mage::getSingleton('customer/session')->getCustomer();
echo $customerData->getStoreId();
} ?>
If it's 0 - that's the case.
Related
When I echo my own variable to a div container it comes out as plaint text (unformatted). I don't understand why echoing a Magento variable comes out formatted but mine doesn't? Here's my code, in particular the <?php if(!isset($specialPrice)): { ?> section which I created. Here is the code:
<div class="product">
<a href="<?php echo $_item->getProductUrl() ?>"
title="<?php echo $this->escapeHtml($_item->getName()) ?>" class="product-image"><img
src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail') ?>"
alt="<?php echo $this->escapeHtml($_item->getName()) ?>"/></a>
<div class="product-details">
<p class="product-name">
<?php echo $this->escapeHtml($_item->getName()) ?>
</p>
<?php $specialPrice = $productToCheck->getData('special_price');
$orignalPrice = $productToCheck->getData('price');
?>
<?php if(!isset($specialPrice)): { ?>
<?php echo $product['price'] ?>
<?php } else: { ?>
<?php echo $specialPrice ?>
<?php } endif ?>
</div>
</div>
Echoing $product['price'] shows up with its CSS like this:
but if it enters the ELSE statement to display my variable it shows like this:
Does anyone know what could be going wrong?
$product['price'] returns you a unformatting price value.
Maybe you can call a block function, for example $block->getPrice() and in getPrice() you need to format the price by your custom preferences.
If you want to add styles to your price value then you need to use a magento tag class
I have been fixing this store, based on magento. The main problem of this is that Some of the products display on the store view has incorrect size (which is attribute)
If you have a look at the picture, on the grid view (list.phtml) the size is US 16/ UK 18 / EUR 48 while on the single view page (view.phtml) it is US 6/ UK 8/ EUR 38.
Have a look at this link
http://www.sequinqueen.com/shop/in-stock.html
I have gone through the code in the view.phtml and appear that the code request the attribute value correctly according to the code below
<?php
$categories =$_product->getCategoryCollection();
foreach($categories as $_category) {
$cat_arr[] = $_category['entity_id'];
}
if($currentCategoryId==102){
// CATEGORY ID = 102 is IN-STOCK PRODUCT CATEGORY
$sizeStock=$_product->getAttributeText('size');
$day="Ready To Ship";
$searchfabric=$_product->getSearchfabric();
$searchcolor=$_product->getSearchcolor();
$make=$_product->getHandmake();
$handmake="HandMake";
$topname=$_product->getTopname();
<?php $i=$j+1;?>
<?php $j=$j+1;?>
<?php if($j<5){?>
<?php if ($i%$_columnCount==1): ?>
<ul class="products-grid">
<?php endif ?>
<?php if($j==1):?>
<li class="item first" style="height:434px; background:#FFF;">
<?php echo $this->getChildHtml("catalog"); ?>
</li>
<li class="item">
<?php echo $topname; ?>
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(162,324); ?>" width="162" height="324" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<div style="width:100%; border-bottom:none; height:80px;">
<?php echo $this->getPriceHtml($_product, true) ?>
<?php if($make==1){ echo "<p>".$handmake."</p>";}else{}?>
<?php if($currentCategoryId==102){?>
<!-- display size -->
<p><?php echo $sizeStock; ?></p>
<?php } ?>
<p> <?php echo $day; ?></p>
</div>
</li>
so it came to my thought that it might be something in the store backend, somewhere around attribute modification.
Here is how the previous developer sorted and arranged the position of the size values I am not sure if this is the cause of problem.
Anybody is familiar with this problem?
Any answer is appreciated.
thank you in advance.
Did you try to reindex product data from "System"->"Index Management" ?
Please use this
$attribute_value = $product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($product);
I have created a product attribute called product_downloads, I can put a file name there and it appears in the product view page in the tab "Additional Information" with a link to the file name. I have successfully implemented this idea for one download, but for some products I will have multiple downloads...
Like I said, I have the code working with one download per product, all that took was a small amount of code inside of app/design/frontend/base/default/template/catalog/product/view/attributes.phtml
Where the original code was:
<?php foreach ($_additional as $_data): ?>
<tr>
<th class="label"><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php endforeach; ?>
this is the code I have replaced that with:
<?php foreach ($_additional as $_data): ?>
<?php if ((string)$_data['value'] != '' and $_data['value'] != 'N/A'): ?> <!-- IF NOTHING DO NOTHING-->
<tr>
<th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
<?php if ($_data['code'] == 'product_download'): ?>
<td>
Product PDF
</td>
<?php else: ?>
<?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?>
<?php endif; ?>
</tr>
<?php endif; ?>
<?php endforeach; ?>
This works perfectly, however... What I need now is to look at the value of product_download, if it has a comma(or some other divider, if this would interfere with a csv format) make two separate links to two seperate files..
One major thing to note... I rely heavily on MAGMI, which is why I have taken this route as no extension allows me to massively import attachments to products.
This is for spec sheets and such... some products have multiple spec sheets. I want to use a single attribute to store multiple file names and have code that will differentiate between the two.
you can use logic with explode function And change your if condition with my custom code as below
<?php if ($_data['code'] == 'product_download'): ?>
<?php
$product_downloads = explode(",",$_product->getProductDownload());
foreach($product_downloads as $download):
?>
<td>
Product PDF
</td>
<?php endforeach; ?>
<?php else: ?>
<?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?>
<?php endif; ?>
this is just logic you can use as per your thoughts as well.
hope this will sure help you.
I've been working on custom up sells related products script, which is displaying 4 random products.
Problem is:
normal product url is:
/shop/$productname
This sometimes is generating url like: /$productname/
or url like: /catalog/product/view/id/$productID/4/s/$productname/category/$categoryid/
I want to have all my URLs the same so: /shop/$productname
<div class="upsell">
<h2>You might be interested in</h2>
<?php // List mode ?>
<?php $_iterator = 0; ?>
<?php // Grid Mode ?>
<table class="products-grid upsell" id="upsell-product-table">
<tbody>
<tr>
<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount(); $_columnCount=4; ?>
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php if ($i++%$_columnCount==0): ?>
<?php endif ?>
<td>
<?php // Initiate product model
$product = Mage::getModel('catalog/product');
// Load specific product whose tier price want to update
$product ->load($_product->getId()); ?>
<img src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(170); ?>" width="125" height="125" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<h3 class="product-name"><?php echo $_helper->productAttribute($product, $product->getName(), 'name') ?></h3>
<?php echo $this->getPriceHtml($product, true) ?>
</td>
<?php endforeach; ?>
</tr>
</tbody>
</table>
</div>
Try
$this->getUrl('shop').$product->getUrlPath()
instead of
$product->getProductUrl()
for both image and product title.
If your indexes are up to date then
$product->getProductUrl()
Should give you the correct product url.
Do not try to build the url yourself from pieces like the url_key, or url_path and the base url. If you move your website to an other serve you're going to have some issues. Also if you change the config settings for categories in product url you can have problems.
I've been trying to pull one single customer review onto the product page.
I've no code to show as honestly i'm not sure where to start and can't find any mention of it online.
Anyone have any ideas?
I wrote a tutorial earlier on bringing all the review elements onto the product page, so you could follow this tutorial: http://www.e-commercewebdesign.co.uk/blog/magento-tutorials/product-reviews-on-product-view-page.php
All you'd have to do is rename the list block and bring it out in the same way. Then simply modify the loop which brings out the reviews in any way you see fit. E.g. limit to a certain number or only echo out review from a certain user.
EDIT:
To get the latest review is quite simple because the reviews are in date order anyway.
Go to review > product > list.phtml
Replace the code in that file with this:
<?php $_items = $this->getReviewsCollection()->getItems();?>
<div class="box-collateral box-reviews" id="customer-reviews">
<?php if (count($_items)):?>
<h2><?php echo $this->__('Customer Reviews') ?></h2>
<?php echo $this->getChildHtml('toolbar') ?>
<dl>
<?php $r_count = 0; ?>
<?php foreach ($_items as $_review):?>
<?php if ($r_count == 0) { ?>
<dt>
<?php echo $this->htmlEscape($_review->getTitle()) ?> <?php echo $this->__('Review by <span>%s</span>', $this->htmlEscape($_review->getNickname())) ?>
</dt>
<dd>
<?php $_votes = $_review->getRatingVotes(); ?>
<?php if (count($_votes)): ?>
<table class="ratings-table">
<col width="1" />
<col />
<tbody>
<?php foreach ($_votes as $_vote): ?>
<tr>
<th><?php echo $this->escapeHtml($_vote->getRatingCode()) ?></th>
<td>
<div class="rating-box">
<div class="rating" style="width:<?php echo $_vote->getPercent() ?>%;"></div>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php echo nl2br($this->htmlEscape($_review->getDetail())) ?>
<small class="date"><?php echo $this->__('(Posted on %s)', $this->formatDate($_review->getCreatedAt()), 'long') ?></small>
</dd>
<?php } ?>
<?php $r_count++; ?>
<?php endforeach; ?>
</dl>
<?php echo $this->getChildHtml('toolbar') ?>
<?php endif;?>
<?php echo $this->getChildHtml('review_form') ?>
</div>
I've simple put an interator into the loop $r_count and put a check inside the foreach which prevent it from progressing on the next loop iteration.