Magento - Stocks do not apply to download prices

Initial conditions:

  • Magento 1.7 installed (did not try with previous versions)
  • One (downloadable) product with several downloadable files with prices added to the default product (let a product that costs $ 50 + 2 downloadable files, one free, the other an extra $ 50 )
  • A new ad campaign (catalog price rule) that applies to all products (say -20% )

More about promotion:

Applies to all products, all groups are active and applied, apply "as a percentage of the initial price", allow a discount on offal → Yes, stop the further rule for processing → No

Expected Result:

Price for a product with a file of $ 50: $ 80 (80% of $ 100)

Actual result:

Price for a product with a file of $ 50: $ 90 (80% of the initial $ 50 and the full price for the download file).

Output:

Promotion does not apply to additional prices that can download downloaded files.

Question (s):

  • Is this the desired behavior for uploaded files? Or is this a mistake?
  • Any tips on how to change the code (eventually create a module) to make it work properly? (Only tips, that is, what to renew)
+4
source share
2 answers

Links / downloads are not its entities (therefore, it does not have a price_index table and is not considered as products)

There are 2 ways to use advertising in products.

  • Catalog price rules

  • Shopping Cart Rules

As your question stated that you used the catalog price rules, I resolved your question using the catalog price rules.

Create a module and rewrite the model

Mage_Downloadable_Model_Product_Type 

======

 <global> <models> <downloadable> <rewrite> <product_type>Web_Eproduct_Model_Downloadable_Product_Type</product_type> </rewrite> </downloadable> </models> </global> 

and the code below calculates the price of each link on the fly (even if you have more than one rule applied to the same product)

 class Namespace_Modulename_Model_Downloadable_Product_Type extends Mage_Downloadable_Model_Product_Type { public function getLinks($product = null) { $product = $this->getProduct($product); $wId = Mage::app()->getWebsite()->getId(); $gId = Mage::getSingleton('customer/session')->getCustomerGroupId(); $catalogRules = Mage::getSingleton('catalogrule/resource_rule')->getRulesFromProduct('',$wId,$gId,$product->getId()); /* @var Mage_Catalog_Model_Product $product */ if (is_null($product->getDownloadableLinks())) { $_linkCollection = Mage::getModel('downloadable/link')->getCollection() ->addProductToFilter($product->getId()) ->addTitleToResult($product->getStoreId()) ->addPriceToResult($product->getStore()->getWebsiteId()); $linksCollectionById = array(); foreach ($_linkCollection as $link) { /* @var Mage_Downloadable_Model_Link $link */ $link->setProduct($product); $link->setPrice($this->calcLinkPrice($catalogRules,$link->getPrice())); $linksCollectionById[$link->getId()] = $link; } $product->setDownloadableLinks($linksCollectionById); } return $product->getDownloadableLinks(); } public function calcLinkPrice(array $rules = array(),$productPrice = 0 ) { foreach($rules as $ruleData) { $productPrice = Mage::helper('catalogrule')->calcPriceRule( $ruleData['action_operator'], $ruleData['action_amount'], $productPrice); } return $productPrice; } } 

I tested it and confirmed its work, as you expect :)

Try it and let me know your thoughts :)

There is another way to achieve this if you use the Price Rules in the shopping cart, which I will post later.

+1
source

Magento, Catalog, and Shopping Price Price rules have 2 types of price rules. Catalog rules are enforced for products before they are added to the basket, while basket price rules apply in the shopping basket.

You must set this promo as a basket price rule .

-1
source

All Articles