Jump to content

Inventera lager och produkter med attribut


Recommended Posts

Hej!

 

Jag har produkter med flera olika storlekar.

 

Hur i hela fridens namn kan man inventera detta?

 

Prestashop visar ju summan för alla storlekar, inte varje enskild storlek.

 

Anta att du säljer en Nike t-shirt. Den finns i tre storlekar, small, medium och large.

Du har 2 small, 4 medium och 1 large i lager. Prestashop visar bara summan av t-shirten. 7 stycken i lager.

 

Önskvärt vore:

 

Nike T-shirt

  • Small: 2
  • Medium: 4
  • Large: 1

 

Har sökt men kan inte hitta någon information om detta.

Antingen finns det inte, eller så är jag snurrig?! :blink:

 

Blir lurigt att inventera lager till årsskiftet :wacko:

Edited by Aknot (see edit history)
Link to comment
Share on other sites

Man borde kunna fixa en dump med en prisfil som mall, frågan är hur man fiskar fram attributen...

 

Någon kunnig kanske har tips?

 

En grund att börja med:

include(dirname(__FILE__).'/config/config.inc.php');
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
 $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return str_replace('/handkraft/inv.php','', $pageURL);
}
function GetCategory($category,$lang)
{
$retur = array();
$retur[0] = $category->name;
if($category->level_depth>0)
{
$i = $category->level_depth;
$s = 1;
do {
$subcategory = new Category(intval($category->id_parent),$lang);
if($subcategory->id!=1)
	$retur[$s] = $subcategory->name;
$i = $subcategory->level_depth;
$category = $subcategory;
$s++;
} while ($i > 0);
}
$result = array_reverse($retur);
$categorystring = "";
foreach($result AS $str)
{
$catname = explode('.',$str);
if(sizeof($catname)>1)
$categorystring.= $catname[1].' | ';
else
$categorystring.=$str.' | ';
}
return rtrim($categorystring,' | ');
}
$lang = intval(Configuration::get('PS_LANG_DEFAULT'));
$productClass = new Product();
$id_currency = intval(Configuration::get('PS_CURRENCY_DEFAULT'));
$currency = new Currency(intval($id_currency));
echo "<table border='1'>";
echo "<tr><td>Produktnamn</td><td>Pris inkl moms</td><td>Kategori</td><td>Produkt-URL</td><td>Lagerstatus</td></tr>";
$products = $productClass->getProducts($lang, 0, null, 'name', 'ASC', false);
foreach ($products as $key => $product)
	{
	 $price = number_format(Tools::convertPrice($product['price'], $currency), 2, '.', '');
	//ADD TAX TO PRICE
	 $tax = $product['tax_rate'];
	 $tax = $tax/100;
	 $tax = $tax + 1;
	 $price = $price * $tax;
	 if($product['reduction_from']==$product['reduction_to'])
	 {
		//Is set to forever
		if($product['reduction_price']!='0.00')
		{
			//VALUE DISCOUNT
			$price = $price - number_format(Tools::convertPrice($product['reduction_price'], $currency), 2, '.', '');
		}
		else
		{
			if($product['reduction_percent']!='0')
			{
				//% DISCOUNT
				$deductproc = $product['reduction_percent'] / 100;
				$deductproc = $price * $deductproc;
				$price = $price - $deductproc;
			}
		}
	}
	 else
	 {
		//Is not set forever
		//convert dates
		$exp_date = $product['reduction_to'];
		$todays_date = date("Y-m-d");
		$today = strtotime($todays_date);
		$expiration_date = strtotime($exp_date);
		if($expiration_date > $today)
		{
			//DISCOUNT VALID
			if($product['reduction_price']!='0.00')
		{
			//VALUE DISCOUNT
			$price = $price - number_format(Tools::convertPrice($product['reduction_price'], $currency), 2, '.', '');
		}
		else
		{
			if($product['reduction_percent']!='0')
			{
				//% DISCOUNT
				$deductproc = $product['reduction_percent'] / 100;
				$deductproc = $price * $deductproc;
				$price = $price - $deductproc;
			}
		}
		}
	}
	 $category = new Category(intval($product['id_category_default']),$lang);
	 $categoryname = GetCategory($category,$lang);
	 $imageUrl = Product::getCover(intval($product['id_product']));
	if($product['manufacturer_name'] == "")
		$product['manufacturer_name'] = "-";
	if($product['location'] == "")
		$product['location'] = "-";
	switch (utf8_decode($categoryname))
	{
		case "Insert name of cat not to be shown": break;
		default:
		 echo "<tr><td>".htmlentities(utf8_decode($product['name']))."</td><td>".
		 number_format(Tools::convertPrice($price, $currency), 2, '.', '')."</td><td>".
		 $categoryname."</td><td>".
		 curPageURL().'/product.php?id_product='.$product['id_product']."</td><td>". //PRINT PRODUCT DIRECT URl
		 $product['quantity']. //IN STOCK STATUS
		 "</td></tr>";
	}
}
echo "</table>";
?>

 

/Mats

Link to comment
Share on other sites

  • 2 weeks later...

Jag har modifierat ovanst. php-fil till att lista alla varor inkl. de med attribut, koden behöver dock rensas upp innan jag vågar visa den för någon. :-)

Sedan har jag ett par problem:

1. $product['quantity'] trodde jag skulle innehålla lagerstatus på varor utan attribut, men det gör den inte, måste jag hämta den ur databasen eller finns den i ngn annan variabel?

2. Listan jag får fram är osorterad, ngn som har tips? T.ex. sort($namn); fungerar inte.

Output som jag har det nu kan man se på http://mohsart.se/handkraft/inv.php

 

/Mats

PS detta är alltså endast en dump, som man t.ex. kan skriva ut och använda vid inventering

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...