Magento - Where do I go to edit file that outputs the sitemap? - magento

I would like to update the template that generates the google sitemap in Magento 1.5.
Reason being, Magento is using the URLKey (e.g. /my-jacket.html) and not the full URL with category (e.g. /outerwear/jackets/my-jacket.html).
I'm doing this in another place on the site (an .html sitemap) and it works great. When looping through products inside a category...
// get the categories for this product
$_categories = Mage::getModel('catalog/product')->load($product_id)->getCategoryIds();
$_category = Mage::getModel('catalog/category')->load($_categories[0]);
// build the URL path
$url = Mage::getUrl($_category->getUrlPath()).basename($_product->getUrlKey());
// only problem is this will be /category/category2.html/my-jacket.html
// so strip the .html and put it on the end
$url = str_replace(".html","" ,$url) . '.html';
It's ugly but works. Anyway, I want to do the same to the google sitemap that gets generated, but after much searching for where it is generated, I can't find it. Anyone point me in the right direction?

I'm fairly certain that there's no simple template to edit. The XML generating happens inside of a model, specifically: Mage_Sitemap_Model_Sitemap::generateXml().

Related

Oscommerce display default product image and prevent it from deletion

I am working on an oscommerce project where i want to display default product image (i.e no image available) if product image is not uploaded.And even i want it to prevent from deletion.I have tried to upload product not available image for 2-3 products but when deleting products i.e final last product image also gets deleted from the folder.I want that if user doesn't upload image then by default no_product_available.jpg should be shown in CATEGORIES.php as well as PRODUCT_INFO.php.
Can anyone help me to do this ? I am using oscommerce default template.
I think I understand what you would like to do... Pretty much you're saying that if someone doesn't upload an image with a product or category then you would like the no_image.jpg image to be displayed instead of nothing being displayed. Additionally, you would like for the no_image.jpg to not be deleted if the category or product is deleted. I think I can help with this...
You need to modify the tep_image() function located in catalog/includes/function/html_output.php
Replace...
if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
return false;
}
With...
if (!is_file($src)) {
$src = "images/no_image.jpg";
}
Now when you use the tep_image() function if no image was uploaded or if the file is specified but missing from the server then no_image.jpg will be displayed. When the category or product is deleted the is no_image.jpg file is not associated with the category or product so nothing is deleted. Obviously, replace "images/no_image.jpg" with the correct location and filename for your default no image file. Also, you may wish to modify the code above to get the specific behavior you want but this is a good starting point to achieve what you want.
The index.php and product_info.php pages use tep_image()... So, you should be all set there. If you're making your own page or modifying an existing one then you would of course need to use the tep_image() function to get the no_image.jpg output functionality. The parameters for tep_image() are...
tep_image($src, $alt = '', $width = '', $height = '', $parameters = '')
UPDATE:
tep_image should already be in both the index.php (the page that generates the category/product list pages) and product_info.php. Just open either file and search for "tep_image" without quotes or parentheses. You should find several instances in both files. Examine the code to understand what has already been done so that when you add a new image you understand the correct syntax.
Pretty much just place tep_image where you want your new image to show up on the page. You need to be familiar with HTML and PHP to read through the page and determine where you want the image placed. If you want to move the current image then you might be able to just cut and paste the current tep_image code to a your new location.
You can also use "Inspect Element" in Chrome in the right click menu to help determine location. Just open the page you want to add an image to and right click in the area you want to add an image to. Then look at the surrounding page source code. Now you have an idea what to look for in the PHP file.
BTW, the index.php page is a little tricky. That page is responsible for the homepage, category listing pages, and product listing pages. Also, there are several other module PHP pages that are Included (so the source code is in a different file that you'll need to track down if that's the area you want to add the image to). Make sense ;-)
Give it a try and write back with what want specifically and you did to achieve it. There are lots of people that have helped me in the past. So, I'm happy to help.

Magento Not Translating Wishlist Product Name and Description

I have a developmental Magento Store I'm setting up with two languages. Everything works perfect except the SideBar Wishlist and the "My Account" Wishlist displays the Spanish option no matter what. Everything switches i.e. the "My Wishlist" title header, even the email to friend box that automatically writes in "Please, enter your comments..." changes correctly. But the product name and discription remians in Spanish. I've tried this suggestion here: Wishlist donĀ“t capture store views lenguage
Has anyone figured out how to fix this or what I might have set incorrectly?
Thanks
I had this problem as well on Magento 1.6.2CE. - while switching store languages product names remain in default language.
On a file Wishlist\Model\Item.php arround line 319 you need to remove the line of code:
public function getProduct()
{
$product = $this->_getData('product'); // <-- remove this line
The $product object is reloaded again with the correct store filter.
I don't really understand the scenario, but based on your title I had came up with this.
By any chance, did you manually code the text on a HTML block?
I have came across with this problem, and what I did is find the code snippets where the text is being called. There I changed it with the code below, instead of directly using the text itself. Hope that it makes sense.
<?php $this->__('Customers'); ?>

How do I place Magento theme blocks?

I am using two plugins, easycatalogimg and bannerslider.
For sanity purpose, I am using the default Magento theme, I am just trying to learn the template engine.
When I enable easycatalogimg, it appears above the bannerslider on the homepage. I am using the following code to call bannerslider.phtml, within CMS -> Homepage.
{{block type='bannerslider/bannerslider' template='bannerslider/bannerslider.phtml'}}
I would like to call the bannerslider, then easycatalogimg. Problem is, I cannot determine what block type easycatalogimg is. If I could, I would just turn off the homepage display, and then place the block beneath that. When I turn on the setting to make easycatalogimg appear on the homepage, it inserts itself above the rest of the page content.
Are there files I can open to determine what block type easycatalogimg is? Then I could do this code, right under the bannerslider.
{{block type='foo/bar' template='default/default/easycatalogimg.home.phtml'}}
Right now, the easycatalogimg appears on the homepage.
IN AN IDEAL WORLD, the solution here would be that I would edit a page like...
frontend/base/default/template/cms/content_heading.phtml
...within that page, call out the bannerslider.phtml and easycatalogimg/homepage.phtml.
Open the template file of the block you want to know the type. If it's a default Magento template, it will generally have the Block_Class name at the top. If it doesn't, run:
<?php echo get_class($this) ?>
That will give you the Block_Class name which then gets translated into Magento's calling convention, such as:
<?php $block = $this->getLayout()->getBlock('core/template') ?>
Where 'core/template' gets translated into Mage_Core_Block_Template

magento catalogsearch search for all products (like a view all brands page )

For a project I need to make a kind of view all manufactures page, I am hoping to use catalogsearch but without any parameters. What I mean is the normal catalogsearch is ran and all shoes in all manufacture categories are returned.
The url that is normally passed is testshop.com//catalogsearch/result/index/?manufacturer=2522&q=shoe%20manufactures this works but when I try to pass testshop.com//catalogsearch/result/index/? (or along those lines) this does not work.
I have not started coding this yet as I am not sure where to begin so need a point in the right direction.
I am thinking of just finding the default category id and using this, but not sure if this is the best option to use.
Any advice or help will be great as always. Will post my finished code on here once complete as I think with magento help can be a bit limited.
Cheers
Jason
Maybe try getting the search Model pragmatically
Here is the code to get the Search model:
$search = Mage::getSingleton('catalogsearch/advanced');
To actually search put in the following:
$search = Mage::getSingleton('catalogsearch/advanced')->addFilters(array('name' => $term));
Then to get the results in an object, enter the following line:
$search->getProductCollection();
Hope this helps
I did it. It was a bit of a hack but works perfectly.
I noticed that if you make a search and remove all the filters you are left with a GET request that look something like this /catalogsearch/result/index/?q=Shoe+Brand . But the filters where not showing on the left hand side as a normal catalogsearch would.
So I found the default category id and added this to the GET request. The GET request now looked like this /catalogsearch/result/index/?cat=2&q=Shoe+Brand .
Although the GET request included q=Shoe+Brand it was not actually using this as search criteria.
This was now returning a catalogsearch page with the default category as a filter.
This was showing default category in the filter and breadcrumbs so I had to change the appropriate phtml files to check for this and display 'all brands' instead of 'default category'.
Hope this helps someone else
Jason

Joomla 1.5 How to divide joomla templet and use different page templet for different page

I am new in joomla and I am going to develop a web site with joomla 1.5.
For the site I have a html css template. Now I want to convert this into joomla template with different files (Header,Footer, sidebar etc).
Is it possible? if yes then how can i do this ?
and how can i make different page temples for my different page (such as about, Products etc)
Please help me....
I would recommend starting here:
http://docs.joomla.org/Creating_a_basic_Joomla!_template
http://docs.joomla.org/JDOC:Joomla!_1.5_Template_Tutorials_Project
I would also recommend visiting http://demo.yootheme.com or http://demo.rockettheme.com and finding one of their free templates (both have one or two, I believe) to download. That way you can analyze how a professional template is built and organized and apply it to your own project.
Your last question: To make different templates to apply to different pages. The simplest way is to follow the directions (above) to make/modify/install a second template. Then use the Joomla template manager and specify which pages apply to which template.
You can certainly create different files for each portion of a page but it's really not necessary in Joomla. There is only one "page" in Joomla, the index.php file. The entire website is built using that file. You can control the different parts - called positions in Joomla - of the website through 3 different methods
using conditional statements that determine whether they need to display at all
using modules to place content in the various positions
using CSS to control the display of each module
While it is technically possible to use multiple template in Joomla, it is almost always unnecessary. In the menu items used to create the pages in Joomla, you can specify a parameter called the page class suffix. You can insert this in to the body tag of your template giving you complete control of each page in the website through CSS rather than coding another template. Use this code to add the page class suffix to your body tag -
<?php
$menu = &JSite::getMenu();
$active = $menu->getActive();
$pageclass = "";
if (is_object( $active )) :
$params = new JParameter( $active->params );
$pageclass = $params->get( 'pageclass_sfx' );
endif;
?>
<body id="<?php echo $pageclass ? $pageclass : 'default'; ?>">
This is compatible with all the big frameworks as well.
If you want to show different header footer and sidebar on each pages. It can be easily possible in joomla. You have to simple create custom module in joomla and you control the display option of this module from the joomla administrator.

Resources