Nopcommerce 2.30 Image Shown in the OrderSummary.cshtml page - asp.net-mvc-3

Before adding an image to the product variant section the image that was shown for the product in the shopping cart was the first product image in the list of product images for that product. Now the Productvariant image is showing.
How do I keep the productvariant image but revert back to using the first image in the product images as the image that shows in the shopping cart?
#if (Model.ShowProductImages)
{
<td class="productpicture">
<img style="border-width: 0px;" alt="#item.Picture.AlternateText" src="#item.Picture.ImageUrl" title="#item.Picture.Title" />
</td>
}

In Nop.Web.Controllers.ShoppingCartController.cs, function PrepareShoppingCartModel:
using (profiler.Step("Picture"))
{
//picture
if (_shoppingCartSettings.ShowProductImagesOnShoppingCart)
{
var picture = _pictureService.GetPictureById(sci.ProductVariant.PictureId);
if (picture == null)
{
picture = _pictureService.GetPicturesByProductId(sci.ProductVariant.Product.Id, 1).FirstOrDefault();
}
cartItemModel.Picture = new PictureModel()
{
ImageUrl = _pictureService.GetPictureUrl(picture, _mediaSetting.CartThumbPictureSize, true),
Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), cartItemModel.ProductName),
AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), cartItemModel.ProductName),
};
}
}
Just change the beginning part of that to:
var picture = _pictureService.GetPicturesByProductId(sci.ProductVariant.Product.Id, 1).FirstOrDefault();

Related

How to display image list from firebase storage in Angular2?

I want to display images in a list which are fetched from firebase database and firebase storage. Following is my code, when I run it browser got unresponsive. Please help me to fix this.
HTML:
<div class="w3-panel" *ngFor="let item of items;">
<img [src]="getImage(image.imageUrl)"/>
</div>
JS : my.component.ts
// imageUrl = question/1/ch1/image.jpg // sample imageUrl format
getImage(imageUrl){
return new Promise((resolve,reject) =>{
this.storage.ref(imageUrl).getDownloadURL().then(url => {
resolve(url);
})
});
}

Magento: SKU No. Changes after product attribute is selected

How do I get the SKU no to change once the the product attribute of an item is selected.
enter image description here
To get sku of selected associated product on configurable product page, please paste the following code in app/design/frontend///template/catalog/product/view/type/options/configurable.phtml in side the script:
spConfig.getIdOfSelectedProduct = function()
{
var existingProducts = new Object();
for(var i=this.settings.length-1;i>=0;i--)
{
var selected = this.settings[i].options[this.settings[i].selectedIndex];
if(selected.config)
{
for(var iproducts=0;iproducts<selected.config.products.length;iproducts++)
{
var usedAsKey = selected.config.products[iproducts]+"";
if(existingProducts[usedAsKey]==undefined)
{
existingProducts[usedAsKey]=1;
}
else
{
existingProducts[usedAsKey]=existingProducts[usedAsKey]+1;
}
}
}
}
for (var keyValue in existingProducts)
{
for ( var keyValueInner in existingProducts)
{
if(Number(existingProducts[keyValueInner])<Number(existingProducts[keyValue]))
{
delete existingProducts[keyValueInner];
}
}
}
var sizeOfExistingProducts=0;
var currentSimpleProductId = "";
for ( var keyValue in existingProducts)
{
currentSimpleProductId = keyValue;
sizeOfExistingProducts=sizeOfExistingProducts+1
}
if(sizeOfExistingProducts==1)
{
alert("Selected product is: "+currentSimpleProductId)
}
}
Now add onchange event to your dropdown in same page:
onchange="spConfig.getIdOfSelectedProduct()"
First code will alert simple associated product id. You can use it in below code now.
jQuery.ajax({
type: "POST",
url: "<?php echo $this->getBaseUrl()?><module_front_name>/<controller_name>/<action_name>/",
data:"id="+currentSimpleProductId,
success: function(msg)
{
alert(msg);
//var data = JSON.parse(msg);
//alert(data.id);
}
});
Now, go to controller file which you have used above and create a new action with name Action and put below code in it:
public function <action_name>Action()
{
$productId = $_REQUEST['id'];
/*$productId is your selected product id. do what ever you want to do here.*/
$product = Mage::getModel('catalog/product')->load($productId);
$productsku = $product->getSku();
$arraygroup = array("sku"=>$productsku);
echo json_encode($arraygroup);
}
Now you can use this information in your phtml file to show sku.
Please let me know if anything is unclear.
Go to Magento admin
In catalog > Manage attribues find sku and look for similar to "Visible on Product View Page on Front-end"
This should remove the sku from product page
Find the configurable product template and insert where you would like to have your SKU
echo $product->getSku()

Magento - Updating attribute IF THE OPTION changed

I really need some support regarding magento:
on this page: https://goo.gl/wTeUtG
If the option changed out of the dropdown, like from 150 Gramm to 200 Gramm, the ingredients (on this page as "Zutaten") also should be updated. But only the price is going to change not the text right into tooltip on "Zutaten".
How or where can I do this?
That's what I have tried so far:
I've created a new attribute and put it into the checkbox.phtml. This is the code for it:
<p>
<label>Zutaten:</label>
<a class="tooltips" href="#">
<img src="https://shop.ellyseidl.de/skin/frontend/base/default/pektsekye/optionbundle‌​/info_icon.gif" width="11px" height="11px" />
<span><strong>Zutaten:</strong>
<?php echo Mage::getModel('catalog/product')->load($_selection->getId())->getData('zutaten'‌​); ?>
</span>
</a>
</p>
But it doesn't change the tooltip once a option is selected
I guess you will have to do it manually with jQuery since you are using it on your page, by adding event on change on the select box with the id="attribute154" or the class="super-attribute-select".
You will have to change the text in the tooltip according to the option being selected.
EDIT:
jQuery('#attribute154').on('change', function() {
var selectedVal = jQuery(this).val();
//If you want to change the tooltip according to the selected text this is how you can get it:
var selectedText = jQuery(this).find("option:selected").text();
if (selectedVal != '') {
var ingredientsText = '';
if (selectedText == '150 Gramm') {
ingredientsText = 'Ingredients for 150 Gramm';
} else if (selectedText == '200 Gramm') {
ingredientsText = 'Ingredients for 200 Gramm';
}
//And so on
jQuery('.tooltips').find('span:first').html('Zutaten:'+' Folgen in Kürze: '+ingredientsText);
} else {
jQuery('.tooltips').find('span:first').html('Zutaten:'+' Folgen in Kürze: ');
}
});
Please have in mind that you must change the text the way you need it. I still don't know what you have to add in the tooltip, but I just tested this on your site and it works. According to the text Folgen in Kürze which means coming soon, not sure what is the text you need to update.
EDIT2:
The ingredientsText var will depend on the quantity of Gramm selected, if they are static you can enter them in the code by yourself, if they are dynamic, you will have to add them somewhere in the HTML in a hidden <div> for example and then fetch them with JS from there.

In Magento,how can i add different image for same product that was assigned to more than one category,When it is in different categories

I Have a product for example,t-shirt that is added to men's category and women's category.Now I want to display a woman's image of that t-shirt on women's category & man's t-shirt image in men's category.
Is there any possiblities for the above without creating the same product again.
If possible kindly provide idea for it.
Ok fair enough. Here's a quick solution to your problem. It's a bit scrappy, but you get the idea. In this example I assume your ladies category has an ID of 123, and the image you want to show in the ladies category is the product's second image;
$otherImage = false;
$catId = 123; // The id of the category to show a different image on
$imageNumber = 2; // The position in the gallery of the image you want to show
$currentCatId = Mage::getSingleton('catalog/layer')->getCurrentCategory()->getId();
if($currentCatId == $catId) { // This is the category you wanted
$count = 1;
$gallery = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages();
foreach ($gallery as $image):
if($count == $imageNumber) {
// This is the image you want
$otherImage = $this->helper('catalog/image')->init($_product, 'image', $image->getFile())->resize(180);
}
$count++;
endforeach;
}
if($otherImage) { echo '<img src="'.$otherImage.'" />'; } else { echo '<img src="'.$this->helper('catalog/image')->init($_product, 'small_image')->resize(180).'" />'; }
There is no native way to do this in Magento. Product images can be set per store view but not per category. I can think of various ways you could achieve this, but unless your portfolio is huge, I would recommend you either use a unisex image (maybe both male and female) or create a separate product for each gender.
T

Magento configurable product stock =0

I have this custom code in my list.phtml to display an image when product qty goes 0:
<?php $stock_count = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
if ($stock_count <1) {
echo '<span style="position:relative;top:-230px;float:right;"><img src="http://www.mysite.com/images/ico_outofstock.png" border=0></span>';
}
?>
Problem is that if product is Configurable it will still display the out of stock image.
What i need is to add something like
if($_product->isConfigurable()) {
to the above code, so the outofstock image will be displayed only for simple products.
Thanks

Resources