magento create own package or use default - magento

The main reason I like creating a fresh package is that it allows you to keep a clean separation between your store themes and the default bundled Magento themes. On the other hand most extensions install layout and template files to app/design/frontend/default/default/ and if your theme is installed under the default package magento will find the extensions frontend files or else you'll have to copy extension files to app/design/frontend/package/default/ always. So it's a little more work using your own package.
I'm curious to see if I'm missing anything else so what are some of the benefits of creating your own theme package in Magento as opposed to using the default package?

First of all, creating a new package is something that Magento Official user guide is required to do.
http://info.magento.com/rs/magentocommerce/images/MagentoDesignGuide.pdf
Here is what it says:
"Please ignore legacy Magento instructions and tutorials that instruct you to create your custom theme inside of the default design package, or to edit files in the default/default directory directly. Rather, the method that affords the best upgrade path for your theme and the most protection from accidental changes is to create a new design package and to create your custom theme inside of there."
My personal logic for creating a new package is if Magento requires few store views and they have differences, I need to have my own 'default' theme and that's exactly what I get by creating my own package (Magento will look for files in the my_theme theme in custom design package, then in the default theme and then fallback to the base package)

If you use default/default, and third-party extensions you use place their files in default/default, then you can't override those files - you have to edit them directly.
So, by
fixing the third-party extension in a vendor/upstream branch
using your own package
you can override only the templates/layouts you need in your package.

The two folder /app/design and /skin are identical(Mirror image we can say).Keep all the css,image files under /skin/your_theme directory and .phtml for layouts in /app/design/your_theme folder.

the default/default package is bad designed from my point of view.
If you use your own package the extensions cannot use your default-directory (?Right?).
I would suggest to add a field default-package.
I use this work-around now - config.xml:
<core>
<rewrite>
<design_package>Your_Extension_Model_Design_Package</design_package>
</rewrite>
</core>
Model/Design/Package.php
class Your_Extension_Model_Design_Package extends Mage_Core_Model_Design_Package
{
/**
* Use this one to get existing file name with fallback to default
*
* $params['_type'] is required
*
* #param string $file
* #param array $params
* #return string
*/
public function getFilename($file, array $params)
{
Varien_Profiler::start(__METHOD__);
$this->updateParamDefaults($params);
$result = $this->_fallback($file, $params, array(
array(),
//'_package' is new. Uses this package when looking for default theme
array('_theme' => $this->getFallbackTheme()),
array('_theme' => self::DEFAULT_THEME, '_package' => 'default'),
));
Varien_Profiler::stop(__METHOD__);
return $result;
}
}

Related

Is there any way to change the creator PDF generation in spipu/html2pdf

I've been using spipu/Html2Pdf version 5.2 in laravel 5.8 to generating PDF, and trying to set my own creator name on the PDF (by default the creator is Html2Pdf - TCPDF)
Is that any way to change it via Html2Pdf class (without modifying the vendor)? or am I allowed to do that?
The creator name comes from TCPDF package (A package Html2Pdf uses) and I think it can be changed with the following:
$html2pdf = new \Spipu\Html2Pdf\Html2Pdf('P', 'A4', 'en');
$html2pdf->pdf->setCreator('CREATOR NAME');

How to properly override a core JS file in Magento2

We are attempting to override the behavior of Bundle Products in Magento2, specifically, to enable user defined quantities for Checkbox type products within the bundle.
We have written an extension, and followed instructions about how to replace a default JS component found here: http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/custom_js.html
Our requirejs-config.js within our extension's frontend (app/code/Endertech/BundleExtended/view/frontend/) view looks like:
var config = {
"map": {
"*": {
'Magento_Bundle/js/price-bundle': "Endertech_BundleExtended/js/price-bundle"
}
}
};
This is having the effect of loading BOTH the core Magento2 price-bundle.js AND our modified version... and the customization we've added to our modified version is not executing... presumably because the Magento2 core version is loading first.
We expected for this revision to PREVENT the core version from loading in favor of ours.
Perhaps we are approaching the problem from the wrong direction, or have some other misunderstanding.
We are seeking a solution to have our modified price-bundle.js be loaded in lieu of the built-in that comes in the Magento Bundle module... or at least a way to override specific methods within and is required here (vendor/magento/module-bundle/view/frontend/requirejs-config.js).
If our approach is wrong, we'd be happy to be corrected!

Add PHPWord to Joomla

I need to add the quite excellent PHPWord - https://github.com/PHPOffice/PHPWord to a Joomla 2.5 project.
I have added the PHPWord files to the plugins folder (might not be the correct choice) and have the following code
$phpWord = new \libraries\PhpOffice\PhpWord\PhpWord();
The class is not found as it is not autoloading. How would I load these classes in Joomla and it there a better folder than plugins that will will autoload?
I have added these lines
JLoader::discover('PhpWord', JPATH_LIBRARIES . '/PhpOffice/PhpWord/');
$phpWord = new PhpWord;
Inside the PhpWord folder is Phpword.php and autoloader.php, as well as several other scripts.
As said in the comment above in Using_own_library_in_your_extensions they explain how to import a library for Joomla 2.5 and Joomla 3.
Now assuming that the tutorial is correct and JLoader::discover is working I would say that the issue is that you have PHPWord in the plugin folder and with JLoader::discover you are searching in /libraries/PhpOffice/PhpWord/.
So
copy /PhpOffice/PhpWord/ in libraries
try to use again JLoader::discover('PhpWord', JPATH_LIBRARIES . '/PhpOffice/PhpWord/');
Reading the documentation of PhpWord I found that you can also directly require the library and use it in this way:
// be sure that the path match in your joomla
require_once 'libraries/PhpWord/Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register();
// Creating the new document...
$phpWord = new \PhpOffice\PhpWord\PhpWord();

How To Detect User Profile Change (Event) in Joomla Programmatically?

We are in the process of building a user synchronization plugin for Joomla 2.5 (gets Joomla users and sends them to another platform via a JSON API call). This all works fine, however once copied, the updates on the profiles in Joomla don't get reflected to the external platform.
I see that there are some events such as onUserAfterSave and onUserBeforeSave, but as far as I understand, these are only available for plugins and not for components (we are building a component with frontend and backend).
So my question is, how do we detect programmatically that the user has changed his profile somehow (name, email or password) and execute something in our component accordingly.
You need to create a user profile plugin. You can pack the plugin together with your component in a package when distributing it. It is quite common in Joomla to have extensions contain 1-2 components, a module and a plugin. This is how Joomla separates specific jobs in specific extensions.
Good examples on how to do it are already inside here:
/plugins/user/
Here is your method signature:
/**
* #param array $user Holds the new user data.
* #param boolean $isnew True if a new user is stored.
* #param boolean $success True if user was succesfully stored in the database.
* #param string $msg Message.
*/
public function onUserAfterSave($user, $isnew, $success, $msg)
{}
Basically inside the method you can do whatever you want, in your case probably updating some tables from your component.

How do I change the currency symbol in Magento 1.5.1.0?

I'm trying to change the price format in Magento ver. 1.5.1.0 from
€8.49
to EUR 8.49
I have been looking through lots of posts and forums but it didn't work out.
I tried to follow the instructions but it didn't work out so far.
Cache is deactivated.
/lib/Zend/Locale/Data/en.xml
<currency type="EUR">
<displayName>Euro</displayName>
<displayName count="one">euro</displayName>
<displayName count="other">euros</displayName>
//added <symbol>EUR</symbol> here
</currency>
/lib/Zend/Locale/Data/root.xml
<currency type="EUR">
<symbol>€</symbol> => changed to <symbol>EUR</symbol> didn't work
</currency>
And no, i don't want to change the core /Zend files or use str_replace.
Thanks for your help!
Try to grep in your version root and you'll see that it is locale based so you just might need to change t in multiple files.
grep 'type="EUR"' . -rsn
don't forget to clear cache afterwards before observing the changes in front-end
rm -rf var/cache/*
You can use free extension Currency Manager
Or you can write your own simple module and override function format() in Mage_Directory_Model_Currency model.
public function formatTxt($price, $options=array())
{
$options['display'] = Zend_Currency::USE_SHORTNAME;
return parent::formatTxt($price, $options);
}
P.S. You can loose your changes in /lib/Zend/Locale/Data/*.xml files after Magento upgrade.

Resources