I have a custom Category tpl page in OpenCart. Just recently I was about to wrap the products loop with this code:
<?php
$ids=array(444,443,145,97,459,460,454,451,450,449,445,446,447,448,457,456,387,385); // array of product id's
?>
<?php
foreach ($products as $product){
if(in_array($product['product_id'],$ids)) {
//Display item
}
}
?>
This code lets me choose specific products that I want to be displayed on this page. It works great! My problem now is that I have more than 16 products to display, and in my opencart setting my item limit is set to 16. I cannot change the settings because it would change all the other pages on my store.
Is there a way I can do this on the template page? Or, if I have to, the category controller? I would love to be able to add code to the loop. But Im up for any solution. Thanks!
I just edited the Controller file:
if ($category_info['category_id'] == '132'){
$limit=1000;
}
Now if my category has the id of 132, it will display all the products on that particular page.
Related
That's my doubt. I have to export one XML file for each storeview on a magento hosting. This catalog has to contain all products available by storeview. The info that i need to export is at least: SKU, name, description,images url, categories which each product belongs and products URL.
I already have done the logic, but I am having problems with filtering the products, what I am doing now it's :
public function getXmlForAllStores()
{
foreach ($this->_storeManagerInterface->getWebsites() as $site):{
foreach ($site->getGroups() as $store): {
$rootCategoryId = $store->getRootCategoryId();
$rootCategory = $this->_rootCategory->load($rootCategoryId);
$catIdArray = $this->toIntArray($rootCategory->getAllChildren(true));
foreach ($store->getStores() as $storeview):{$collection = $this->_categoryLayer
->setCurrentCategory($rootCategory)
->getProductCollection()
->addWebsiteFilter($site);
//get xml string
$xmlData= $this->toXml($collection, $store, $storeview);
$fileName = $storeview->getCode()."feed.xml";
echo "filename: ". $fileName. "<br>";
//make file
$this->makeFile($xmlData,$fileName);
}endforeach;
}endforeach;
}endforeach;
return "ok";
}
as you can see, i am iterating on lowest scope to get different xml files for all storeviews on all stores-group contained on each website. but i can't find the way to retrieve data according the storeview, like name, description and more critical, the product url according the storeview.
the setstoreid filter doesn't work for what i want.
any help would be great, thanks for reading!
This feature is already available by default in Magento. For getting products for a particular store view, do the following:
Go to your Catalog > Products
Select a store view above the product list.
You are now viewing all products included in this store view.
Once you have the correct store view selected, select the products you want to Enable or Disable using the checkbox on the left.
Now, using the Actions dropdown menu on top right of the product list, choose 'Change Status', select 'Disabled' or 'Enabled' and hit the Submit button.
Using Catalog Price Rules, I'm trying to show that there was a discount applied to the particular product once viewing the cart page. Currently, Magento stops showing the "crossed-out" price when viewing the cart, so it doesn't appear that they received a discounted price unless they go back to the product / catalog page.
The area in question is located around line 103:
template > checkout > cart > item > default.phtml
What would be the proper way to show the original price next to the current price within this section? I serioulsly have no idea how it works and can't find anything on the net regarding this, as it's much different setup than anything inside View.phtml
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
<?php else: ?>
<?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?>
<?php endif; ?>
Due to the random / low responses I get from alternate StackExchange websites, I've also posted this question here: https://magento.stackexchange.com/questions/42494/show-original-price-in-cart
and will update my question accordingly. Thanks!
You could try using $_item->getProduct()->getPrice() to get the original price.
<?php echo $this->helper('checkout')->formatPrice($_item->getProduct()->getPrice()) ?>
I trying to create product programmatically, but it not showing at category page (at "frontend").
I use next code (yes, bad code, but it is one-time task)
$product = new Mage_Catalog_Model_Product();
...
$product->getResource()->save($product);
$product_id = $product->getId();
foreach (array($default_cat, $category_id) as $cat_id) {
Mage::getSingleton('catalog/category_api')->assignProduct($cat_id,$product_id);
}
It succesfully create product, but when I open category page - it doesn't contain product. When I open product edit page and click "save" - product also added to category page...
What I can do?
UPD. Cache clearing and rendexing doesn't help... And, when I open product edit page - categories list are correct
UPD2. Reason was in qty/stock.
$product->setCategoryIds(1,2,3,4,5)->save()
?
I need to hide some payment methods for specific products.
I tried a plugin but it did not work.
Now I am trying to display the product ID in the cart.phtml page. so i can use jquery to hide the payment. and i want to know how to display products ids in the cart.phtml?
Or if there is another and better way to achieve this result that will be appreciated
Thanks in advance.
EDIT::
<?php if($_item->getProductId() == 27){
?>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(".paypal-logo").hide();
</script>
<? } ?>
I am using the above code in default.phtml but it taking affect on the upper checkout button and not the lower one.
Now I am trying to display the product ID in the cart.phtml page. so i
can use jquery to hide the payment. and i want to know how to display
products ids in the cart.phtml?
If that's how you want to do it:
Location of cart template files: app/design/frontend/default/default/template/checkout/cart/
Location of cart line item files app/design/frontend/default/default/template/checkout/cart/item/default.phtml
Look for where you want to put the product id to go (let's assume after the product name).
Change this:
<?php echo $this->htmlEscape($this->getProductName()) ?>
To this
<?php echo $this->htmlEscape($this->getProductName()) . " " . $this->htmlEscape($this->getId()) ?>
Edit:
If the above doesn't work also try $this->getProduct()->getId() - depending on your version of Magento
in opencart 1.5.1.3 i want to display all categories with images at top and category name at botoom.
once any one click on image or name will goto that category page.
i am trying my best,
even i have featured.tpl file, which is showing featured products on home page, i also try to modify it but its not working.
in featured.tpl i try to change
<?php foreach ($products as $product) { ?>
to
<?php foreach ($categories as $category) { ?>
but this is not working and displaying error
Invalid argument supplied for foreach()
how can i display that?
Thanks
You can't just use $categories in the tpl file, you have to assign the categories to the view using the controller
Open
/catalog/controller/module/featured.php
Find this line around line 10
$this->load->model('catalog/product');
Before it put
$this->load->model('catalog/category');
$this->data['categories'] = $this->model_catalog_category->getCategories(0);
And save