-
Notifications
You must be signed in to change notification settings - Fork 1
Magento Training #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andresmazza
wants to merge
7
commits into
SummaSolutions:master
Choose a base branch
from
andresmazza:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
61a22f1
Git Ignore
andresmazza 89dbd36
GitIgnore
andresmazza aef43a3
Ejercicio 2
andresmazza d216290
Add visibility filter
andresmazza 21defb4
Check is Category
andresmazza c5e467b
tmp
andresmazza 43ec9b5
Override ProductUrl
andresmazza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| .idea/ | ||
| app/etc/local.xml | ||
| var/ | ||
| media/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?php | ||
| /** | ||
| * Created by PhpStorm. | ||
| * User: Andres Mazza <andres.mazza@gmail.com> | ||
| * Date: 29/11/15 | ||
| * Time: 16:13 | ||
| */ | ||
| class Training_Audit_Helper_Data extends Mage_Core_Helper_Abstract { | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Created by PhpStorm. | ||
| * User: Andres Mazza <andres.mazza@gmail.com> | ||
| * Date: 29/11/15 | ||
| * Time: 17:03 | ||
| */ | ||
| class Training_Audit_Model_Observer | ||
| { | ||
|
|
||
| /** | ||
| * Catalog Product After Save (change status process) | ||
| * | ||
| * @param Varien_Event_Observer $observer | ||
| * @return Mage_Sales_Model_Observer | ||
| */ | ||
| public function catalogProductSaveAfter(Varien_Event_Observer $observer) | ||
| { | ||
| $product = $observer->getProduct(); | ||
| $productId = $product->getId(); | ||
| $productName = $product->getName(); | ||
| $userName = '-'; | ||
| if (Mage::getModel("admin/session")->getData('user')) { | ||
| $userName = Mage::getModel("admin/session")->getData('user')->getData('username'); | ||
| } | ||
|
|
||
| Mage::log("Username:".$userName." Action:Change ProductID:".$productId. " ProductName:".$productName); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <?xml version="1.0"?> | ||
| <config> | ||
| <modules> | ||
| <Training_Audit> | ||
| <version>0.1.0</version> | ||
| </Training_Audit> | ||
| </modules> | ||
| <global> | ||
| <models> | ||
| <training_audit> | ||
| <class>Training_Audit_Model</class> | ||
| </training_audit> | ||
| </models> | ||
| <blocks> | ||
| <training_audit> | ||
| <class>Training_Audit_Block</class> | ||
| </training_audit> | ||
| </blocks> | ||
| <helpers> | ||
| <training_audit> | ||
| <class>Training_Audit_Helper</class> | ||
| </training_audit> | ||
| </helpers> | ||
| </global> | ||
| <adminhtml> | ||
| <events> | ||
| <catalog_product_save_after> | ||
| <observers> | ||
| <training_audit> | ||
| <type>singleton</type> | ||
| <class>training_audit/observer</class> | ||
| <method>catalogProductSaveAfter</method> | ||
| </training_audit> | ||
| </observers> | ||
| </catalog_product_save_after> | ||
| </events> | ||
| </adminhtml> | ||
| </config> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <?php | ||
| /** | ||
| * Created by PhpStorm. | ||
| * User: andres | ||
| * Date: 09/12/15 | ||
| * Time: 21:55 | ||
| */ | ||
| class Training_Catalog_Helper_Data | ||
| extends Mage_Core_Helper_Abstract { | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
| /** | ||
| * Product model override | ||
| * | ||
| * @category Company | ||
| * @package Company_Feed | ||
| */ | ||
| class Training_Catalog_Model_Product | ||
| extends Company_Feed_Model_Catalog_Product | ||
| { | ||
| public function getProductUrl($useSid = null) { | ||
|
|
||
| if(Mage::helper('catalog')->isCategory()) { | ||
|
|
||
| $categoryId = Mage::registry('current_category')->getId(); | ||
| $productUrl = parent::getProductUrl($useSid); | ||
| $productUrl .= 'cat/'.$categoryId; | ||
|
|
||
| return $productUrl; | ||
| } | ||
| parent::getProductUrl($useSid); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?xml version="1.0"?> | ||
| <config> | ||
| <modules> | ||
| <Training_Catalog> | ||
| <version>0.1.0</version> | ||
| </Training_Catalog> | ||
| </modules> | ||
| <global> | ||
| <models> | ||
| <training_catalog> | ||
| <class>Training_Catalog_Model</class> | ||
| </training_catalog> | ||
| <catalog> | ||
| <rewrite> | ||
| <product>Training_Catalog_Model_Product</product> | ||
| </rewrite> | ||
| </catalog> | ||
| </models> | ||
|
|
||
| <blocks> | ||
| <training_catalog> | ||
| <class>Training_Catalog_Block</class> | ||
| </training_catalog> | ||
| </blocks> | ||
| <helpers> | ||
| <training_catalog> | ||
| <class>Training_Catalog_Helper</class> | ||
| </training_catalog> | ||
| </helpers> | ||
| </global> | ||
| </config> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Training_Company_Helper_Data | ||
| */ | ||
| class Training_Company_Helper_Data | ||
| extends Mage_Core_Helper_Abstract | ||
| { | ||
| public function isVisible($id) | ||
| { | ||
| switch ($id) { | ||
| case 1: //Not visible | ||
| $result = false; | ||
| break; | ||
| case 2: // In Catalog | ||
| $result = true; | ||
| break; | ||
| case 3: // In Search | ||
| $result = true; | ||
| break; | ||
| case 4: // In Catalog/Search | ||
| $result = true; | ||
| break; | ||
|
|
||
| default: | ||
| $result = false; | ||
| } | ||
| return $result; | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
app/code/local/Training/Company/controllers/Catalog/ProductController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <?php | ||
| /** | ||
| * Created by PhpStorm. | ||
| * User: Andres Mazza <andres.mazza@gmail.com> | ||
| * Date: 30/11/15 | ||
| * Time: 00:02 | ||
| */ | ||
| require_once 'Company/Feed/controllers/Catalog/ProductController.php'; | ||
|
|
||
|
|
||
| class Training_Company_Catalog_ProductController | ||
| extends Company_Feed_Catalog_ProductController | ||
| { | ||
| public function feedAction() | ||
| { | ||
| $id = $this->getRequest()->getParam('id'); | ||
| $product = Mage::getModel('catalog/product')->load($id); | ||
|
|
||
|
|
||
| if ($product->getId() && Mage::helper('company')->isVisible($product->getVisibility()) ) { | ||
| $fields = array( | ||
| 'entity_id', | ||
| 'sku', | ||
| 'name', | ||
| 'description', | ||
| 'visibility' | ||
| ); | ||
|
|
||
| $xml = $product->toXml($fields); | ||
|
|
||
| $this->getResponse() | ||
| ->clearHeaders() | ||
| ->setHeader('Content-Type', 'text/xml') | ||
| ->setBody($xml); | ||
| return $this; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?xml version="1.0"?> | ||
| <config> | ||
| <modules> | ||
| <Training_Company> | ||
| <version>0.1.0</version> | ||
| </Training_Company> | ||
| </modules> | ||
| <frontend> | ||
| <routers> | ||
| <catalog> | ||
| <args> | ||
| <modules> | ||
| <training_company before="Company_Feed_Catalog">Training_Company_Catalog</training_company> | ||
| </modules> | ||
| </args> | ||
| </catalog> | ||
| </routers> | ||
| </frontend> | ||
| <global> | ||
| <helpers> | ||
| <company> | ||
| <class>Training_Company_Helper</class> | ||
| </company> | ||
| </helpers> | ||
|
|
||
| </global> | ||
| </config> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?xml version="1.0"?> | ||
| <config> | ||
| <modules> | ||
| <Training_Audit> | ||
| <active>true</active> | ||
| <codePool>local</codePool> | ||
| <depends> | ||
| <Mage_Catalog/> | ||
| </depends> | ||
| </Training_Audit> | ||
| </modules> | ||
| </config> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <?xml version="1.0"?> | ||
| <config> | ||
| <modules> | ||
| <Training_Catalog> | ||
| <active>true</active> | ||
| <codePool>local</codePool> | ||
| </Training_Catalog> | ||
| </modules> | ||
| </config> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?xml version="1.0"?> | ||
| <config> | ||
| <modules> | ||
| <Training_Company> | ||
| <active>true</active> | ||
| <codePool>local</codePool> | ||
| </Training_Company> | ||
| </modules> | ||
|
|
||
| <frontend> | ||
| <routers> | ||
| <catalog> | ||
| <args> | ||
| <modules> | ||
| <Company_Feed before="Mage_Catalog">Company_Feed_Catalog</Company_Feed> | ||
| </modules> | ||
| </args> | ||
| </catalog> | ||
| </routers> | ||
| </frontend> | ||
| </config> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resuelve el requerimiento, pero estas duplicando código sin necesidad.
Como opción podrías simplemente consultar por la visibilidad y si cumple con el criterio del requerimiento llamas al parent:
parent::feedAction();