I have a Magento installation, with two websites on it:
Retail (default)
Trade
Currently all the prices have been imported as default and so the prices are set the same on both websites. I now need to import the lower prices just for the trade website.
I know this can be done manually per product, but how do I go about importing these prices (with their SKU's so that they only apply to the trade store?
Any help much appreciated!
I suggest doing a Product Export first so you can see all of the columns that are used. Locate a SKU from your Trade store and see what the values are for that column.
You should see a column called _product_websites. In my installation, this column has "base" in it. On yours it will probably say "base" and "trade" (whatever you specified for your website code). You can sort by this column in Excel or other spreadsheet software and remove all of the rows that just have "base" in it so you're left with "trade". Now you can update your prices, save the sheet and re-import your file.
hth
You can simply follow the following Magento blog post:
http://www.blog.magepsycho.com/updating-product-prices-in-magento-in-easier-faster-way/
Just you need to add store_id filter in following method as:
function _updatePrices($data){
$connection = _getConnection('core_write');
$sku = $data[0];
$newPrice = $data[1];
$storeId = $data[2];
$productId = _getIdFromSku($sku);
$attributeId = _getAttributeId();
$sql = "UPDATE " . _getTableName('catalog_product_entity_decimal') . " cped
SET cped.value = ?
WHERE cped.attribute_id = ?
AND cped.entity_id = ?
AND store_id = ?";
$connection->query($sql, array($newPrice, $attributeId, $productId, $storeId));
}
Of course you need to use third column of prices.csv for store_id.
Let me know if that helps.
Related
I know this was discussed before but it's not really working for me. How can i get qty available for location or warehouse my product is now.
(Most of the answers are in old API and this one not really working for me)
class ProductProduct(models.Model):
_inherit = 'product.template'
available_qty = fields.Integer(
string='Qty By Loc',
compute='product_qty_location_check',
)
def product_qty_location_check(self):
if self:
self.available_qty = self.with_context({'location' : self.source_location.id}).qty_available
AttributeError: 'product.template' object has no attribute 'source_location'
To get the quantity by location you need to search the location with the product_id in stock.quant
Use the below sample in your compute function:
quant_sr = self.env["stock.quant"].search([('location_id','=',self.source_location.id),('product_id','=',self.product_id.id)])
qty = 0.0
for quant in quant_sr:
qty += quant.qty
print qty
First you have to find out your location and/or warehouse. There are enough possibilities to do so:
use a wizard which has a field
search by reference e.g. self.env.ref('my_module.my_location')
use other sources
Now you can use them on product.product's _product_available(). Just call that method on one or more products (recordssets) and evaluate the result of this method. To filter for locations and/or warehouses use the context. For example:
# get a recordset of all products
products = self.env['product.product'].search([])
# get a special location (my_location)
location = self.env.ref('my_module.my_location')
quantities = products.with_context(location=location.id)._product_available()
# print the quantities
for product_id, quantity_dict in quantities.iteritems():
print product_id
print quantity_dict
The same is possible with with_context(warehouse=warehouse.id) or even with list of IDs or names: with_context(location=[1,2,3]), with_context(location="My Location")
Magento v1.7.0.2
We've been using this version several years now.
We have several free and paid extensions and last month we created our first bundled product.
When in list view the price is shown as 'Start at 0,00' for some products.
Other bundles products are fine and show the correct minimum price.
I've been searching for a while now, but can't find a workable solution.
Here's a sample page: http://www.scrapwebshop.nl/kado-tip.html
I finally got it working. It is probably not the right nor most efficient way, but the result is what I need. And that is what counts ;)
I now I have a grouped product, so I loop through all associated products, put their prices in an array. Next I sort to get the lowest value on top and get the first array entry.
I hope it helps somebody else:
$associatedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product);
foreach ($associatedProducts as $assoc) {
$prices[] = $assoc->price;
}
sort($prices, SORT_NUMERIC);
$_minimalPrice = array_shift($prices);
$_exclTax = $_taxHelper->getPrice($_product, $_minimalPrice);
$_inclTax = $_taxHelper->getPrice($_product, $_minimalPrice, true)
Each product in magento has indiviual minimum qty for to be in stock
I use magmi to update the stock from an external csv file.
Issue is that on successful updation of csv , magmi does not refer to minimum qty value to set the product "in stock" or "out of stock"
So all my products endup being "in Stock" and only when I edit and save the product in admin it sets it right.
above scenario explained again:
if Current qty= 1 & mim_qty = 05 and in csv qty= 100
after magmi run (re-indexing done)
new qty= 100 and i can see at front end at list.phtml
next
Current qty= 100 & mim_qty = 05 and in csv qty= 3
after magmi run (re-indexing done)
new qty= 3 and **i can see at front end at list.phtml**
following setting is common in bot case
Manage stock = 1;
use_config_manage_stock = 1;
min_qty = 05;
If you want min_qty to be parsed by magmi, then you need to provide it as input to magmi beside qty value.
Magmi relies 95% on input data , not current existing DB data (except not to replicate select/multiselect options,or checking if a product exists, getting attributes metadata)
So , min_qty is not checked against existing value but input value. if no min_qty is set on input, then magmi does not update is_in_stock based on existing value of min_qty.
That's a behaviour i could enhance in next release.
In class Magmi_ProductImportEngine under function updateStock()
Instead of:
$mqty=(isset($item["min_qty"])?$item["min_qty"]:0);
I have added:
$gsql = "SELECT min_qty FROM cataloginventory_stock_item WHERE product_id=?";
$grvalue = $this->selectAll($gsql, array($pid));
foreach($grvalue as $gcalminqty) {
$gfinalminqty = $gcalminqty['min_qty'];
}
$gfinalminqty = (isset($gfinalminqty) ? $gfinalminqty : 0);
$mqty = (isset($item["min_qty"]) ? $item["min_qty"] : $gfinalminqty);
This looks for min_qty in CSV, if not read from Magento, otherwhise use default.
I am using following tutorial to display the most sold product sort by option(Filtering) to display on product listing page in magento?
Tutorial
/app/code/local/Mage/Catalog/Model/Resource/Product/collection.php
<?php
public function sortByReview($dir){
$table = $this->getTable('review/review');
$entity_code_id = Mage::getModel('review/review')->getEntityIdByCode(Mage_Rating_Model_Rating::ENTITY_PRODUCT_CODE);
$cond = $this->getConnection()->quoteInto('t2.entity_pk_value = e.entity_id and ','').$this->getConnection()->quoteInto('t2.entity_id = ? ',$entity_code_id);
$this->getSelect()->joinLeft(array('t2'=>$table), $cond,array('review' => new Zend_Db_Expr('count(review_id)')))
->group('e.entity_id')->order("review $dir");
}
?>
But I want to sort products which are most sold from every category.
How can I do this?
Is there any free extension available for this?
I did the following thing as the client did not want automatically filter most sold product.
I created an attribute "popular" as drop down and give values from 1 to 5.Then marked "Used for Sorting in Product Listing" to Yes.
After this the attribute was visible under sorting options.
In my Magento store I sometimes forget to select 'In Stock' from the dropdown after adding new inventory to an out of stock item.
Is it possible to somehow get a list of all products which have inventory but as tagged as "Out of Stock"?
If you are able to script something real quick.
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter('is_in_stock', 0)
->addAttributeToFilter('qty', array("gt" => 0));
Sadly I can't seem to remember how to put in the >0 in a way that is supposed to work. Maybe someone can comment on that.
What you can do with $products is run it through a foreach loop and then set the is_in_stock to the value of 1 and you should be in business.
Easiest way (I think)
Admin -> System -> Import/Export -> Profiles
Add new Profile
Change to export, give the file a name and a location. Download the file and open in your favorite spreadsheet program. Look for "is_in_stock" - 1 = in stock, 0 = out of stock. Filter by 0 and you'll have a list of all of your OOS items.
You can also check the RSS list for low stock alerts at http://shop.com/index.php/rss/catalog/notifystock/
You have to put
Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()
code in
app/design/frontend/default/[yourtemplate]/template/catalog/product/list.phtml
file to check your product inventory.
The shortest way is:
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($_collection);
Load Products order by Stock And Descending Order
$products
->joinField(
'inventory_in_stock',
'cataloginventory_stock_item',
'is_in_stock',
'product_id=entity_id',
'is_in_stock>=0',
'left'
)
->setOrder('inventory_in_stock', 'desc');