Magento brands by categories: show brand link - magento

I'm setting up a webshop for a client in Magento.
He works a lot with very specific brands, so I wanted to make specific brands pages (for SEO purposes).
I followed the suggestion mentioned here: Mangento Shop By Brand to make categories out of brands.
It all works great, I can access my pages like example.com/brands/brandname.
But now, when in a products view, I want to link to that brand page.
How can I get a list of the categories for that product, or even the specific subcategory.
I thought about filtering categories by their parent_id (my brands page itself). But haven't got a clue how to go about doing it.
I found som info here but doesn't seem to work for my Magento (1.4.1.1)

It seems to do the work: Aitoc commercial module to shop by brand
Or I tried this code with Magento 1.4.1 which display the list/url of category/ies that the product belongs to, inspired of the link you provided and it works, put it in a block to allow the template to display the url:
public function getProductUrl($productId){
$product = Mage::getModel('catalog/product')->load(productId);
$currentCatIds = $product->getCategoryIds();
if ($currentCatIds) {
$categoryCollection = Mage::getResourceModel('catalog/category_collection')->addAttributeToSelect('name')
->addAttributeToSelect('url')
->addAttributeToFilter('entity_id', $currentCatIds)
->addIsActiveFilter();
foreach ($categoryCollection->getItems() as $item) {
/*echo $item->getName();
echo $item->getUrl();
echo '<br>';*/
if($item->getUrl()) return $item->getUrl();
}
}
}

Related

Configurable products not searchable in Magento

My site has a need to have all products as configurable with no associated products (for now). So the site is mostly used as a catalog. We use configurable as opposed to simple products because we anticipate in the future we will add the associated products.
However, I notice that configurable products without associated products are not searchable. I tried to work around this by looking at this piece of code inside the Mage_CatalogSearch_Model_Resource_Search_Collection class.
// search in catalogindex for products as part of configurable/grouped/bundle products (current store)
$where = array();
foreach ($options as $option) {
$where[] = sprintf('(attribute_id=%d AND value=%d)', $option['attribute_id'], $option['option_id']);
}
if ($where) {
$selects[] = (string)$this->getConnection()->select()
->from($resource->getTableName('catalogindex/eav'), 'entity_id')
->where(implode(' OR ', $where))
->where("store_id={$storeId}");
}
I tried to comment out this code but still returns empty. Which code should I comment out?
Thank you
Ensure that the visibility is set to "Catalog, Search" and then under Inventory select "In stock" under stock availability or override the "Manage Stock" setting to "No".
Then of course ensure that indexes and cache are up to date.

To disable url for particular subcategory in magento cart

just got handed a magento site to update. No experience with the cart, so I hope these questions aren't too simplistic. Did search around a bit and haven't been able to find straightforward answers
=> For Some of my accessories showing in magento cart i does not want link on their title and image so how i made this dynamically.
Any help is appreciable
I have create a function in /app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php
public function getCustumcatId()
{
$proid=$this->getProduct()->getId();
$categoryIds=$this->getProduct()->getCategoryIds($proid);
foreach($categoryIds as $categoryId)
{
$category = Mage::getModel('catalog/category')->load($categoryId);
}
return $category->getName();
}
and call it on default.phtml of cart
after getting name i use if and else to remove link thanks for help and comment

Magento Collection: incorrect product category ID in URL

I'm looking to display a featured products collection, based on a featured attribute filter. I get this basically working okay. The part I'm struggling with is that the URL that gets attached to 'getProductUrl()' is wrong.
Comparing the system urls without rewriting them, I noticed that I get this type of url:
catalog/product/view/id/1148/category/6
The category ID at the end is wrong. It shows the parent category ID. If I could get the correct subcategory ID in which those products are assigned, at the end of this URL, then my rewrite would probably work.
Here's my current code, in a featured.phtml template:
<?php
// get all products that are marked as featured
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*');
$collection->addAttributeToFilter('featured', array('Yes' => true));
$collection->setOrder('entity_id', 'desc');
$collection->addUrlRewrite($categoryId);
?>
and
<?php foreach ($collection as $_product) : ?>
Can anybody help? Thanks in advance.
Additional notes: the products are in a subcategory but this collection is pulled on the landing page of its parent category and on the home CMS page.
I get: www.sitename.com/product_url_key.html
I want: www.sitename.com/category_path/product_url_key.html

Display New Products, Filter by Category Ids: in Magento

i have magento 1.5 and i want to display new products Filter by Category Ids. I had try by ->addCategoryFilter($categoryId);
But not working...
I also try this tips, which exactly i want by (Category ids). but it give me error of: "Invalid attribute Category_ids"...
SO can any one display new products in magento by list of Category ids....?
See my reply here How to get all product from a category including its subcategories in Magento?
To filter with Category you need to pass category model data rather then category ID. As like
below.
$category_id = 10;
$catagory_model = Mage::getModel('catalog/category')->load($category_id);
$collection->addCategoryFilter($catagory_model);
Please see this link for more detail http://way2discuss.blogspot.in/2012/07/magento-show-all-products-from-specific.html

How do I get ALL of my product items to show up on the homepage of magento 1.3.2?

I installed Magento v1.3.2.3 and added most of my product inventory. However, I can only get 5 items to display on the homepage. I need all my products to show up there. How?
This is currently the code I am using.
{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}
I found this on the magento community forum.
This link explains how to display products in a particular category on the homepage. You just have to remove the category filter from the code given there to get all the products.
$products = $product->setStoreId($storeId)
->getCollection()
->addAttributeToFilter(‘visibility’, $visibility)
->addCategoryFilter($category)
->addAttributeToSelect(array(‘name’), ‘inner’) //you need to select “name” or you won’t be able to call getName() on the product
->setOrder(‘name’, ‘asc’)
;
change this to
$products = $product->setStoreId($storeId)
->getCollection()
->addAttributeToFilter(‘visibility’, $visibility)
->addAttributeToSelect(array(‘name’), ‘inner’)
->setOrder(‘name’, ‘asc’)
;
That should set you on the right track. Good luck!

Resources