Im making a multi shop module, the module saves / adds to the modules shop tables etc.
This part is fine.
I just have an issue with the GUI its missing the Group names, to me it looks like I'm missing something for a sprintf() I just see the %s and not the group name.
The image shows what I mean.
In my renderform function I have added.
if (Shop::isFeatureActive())
{
$this->fields_form['input'][] = array(
'type' => 'shop',
'label' => $this->l('Shop association'),
'name' => 'checkBoxShopAsso',
'values' => Shop::getTree()
);
}
I wonder do i need to add anything else? all of the other modules I have look fine.
Thanks.
** Updated **
Have just found the template, it is the sprintf() that is not working because if i relace the line it works fine.
{*<label class="tree-toggler">{l s='Group: %s' sprintf=$node['name']}</label>*}
<label class="tree-toggler">{$node['name']}</label>
Any Ideas?
Thanks.
Related
I made a custom field in prestashop.
I would like to know if there is some way to make this field only required on the frontend and not for administrators.
this is my code in Customer class
array('type' => self::TYPE_STRING, 'required' => true, 'size' => 64),
Thanks in advance
Can't think of a quick way to make this possible exactly as you want it, so here are two suggestions:
1 - Remove the 'required' => true from the definition and create some kind of custom validation like if (Tools::getValue('type ') == "") { return false; } in an override of the front office AuthController (Warning: code is completely untested and should definitely be improved, also according to your particular PS version).
2 - Use frontend validation by giving the frontend form field the required attribute (you should do this even if oyu use 1)
due to a large project which will be realised in ZF2, I came across the following problem and I seem to misunderstand the handling of namepaces.
The project will have a lot of modules of similar groups. I will have 4 groups (A, B, C, D) and all modules in group A will deal with input for example. In order to make sure, that we do not end up with a folder containing 200 modules, we want to group the ones that belong together for reasons of cleanliness.
So basically we wish for the following structure:
/config
/module
/MainApplication <- accesses all modules
/groupA
/Module1
/Module2
/groupB
/Module3
/Module4
...
I already adjusted the namespace to groupA\Module1, adjusted the routes accordingly and all the paths seem to be correct and yet I get errors saying that for example the template files cannot be accessed.
Can you give me a hint what you would have to pay attention to when you move a model from /modules/module1 to /modules/subfolder/module1.
What I tried
Changed all namespaces to: -------------------------------------------
groupa\module1[\Controller];
/config/application.php: ---------------------------------------------
...
'modules' => array(
'groupa\module1',
),
...
/module/groupa/Module.php: -------------------------------------------
...
'route' => '/',
'defaults' => array(
'controller' => 'groupa\module1\Controller\Index',
'action' => 'index',
),
...
'controllers' => array(
'invokables' => array(
'groupa\module1\Controller\Index' => 'groupa\module1\Controller\IndexController'
Currently, the module is not supposed to do much. Just showing the index.phtml template. The error I get is the following:
Fatal error: Uncaught exception 'Zend\View\Exception\RuntimeException' with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render template "groupa/index/index";
resolver could not resolve to a file' in /Users/xxx/Sites/zf2helloworld/vendor/Zend/View/Renderer/PhpRenderer.php:461
Stack trace:
#0 /Users/xxx/Sites/zf2helloworld/vendor/Zend/View/View.php(203): Zend\View\Renderer\PhpRenderer->render(Object(Zend\View\Model\ViewModel))
#1 /Users/xxx/Sites/zf2helloworld/vendor/Zend/View/View.php(231): Zend\View\View->render(Object(Zend\View\Model\ViewModel))
#2 /Users/xxx/Sites/zf2helloworld/vendor/Zend/View/View.php(196): Zend\View\View->renderChildren(Object(Zend\View\Model\ViewModel))
#3 /Users/xxx/Sites/zf2helloworld/vendor/Zend/Mvc/View/Http/DefaultRenderingStrategy.php(128): Zend\View\View->render(Object(Zend\View\Model\ViewModel))
#4 [internal function]: Zend\Mvc\View\Http\DefaultRenderingStrategy->render(Object(Zend\Mvc\MvcEvent))
#5 /Users/xxx/Sites/zf2helloworld/vendor/Zend/EventManager/Ev in /Users/xxx/Sites/zf2helloworld/vendor/Zend/View/Renderer/PhpRenderer.php on line 461
Am I missing the obvious? Why can the template not be found? I echoed back the 'template_path_stack' and it seems to be correct:
/Users/xxx/Sites/zf2helloworld/module/groupa/module1/view
I am aware of the reusability of modules and such. We would still love to group modules that belong together into the same folder and preferably access them via the proper URL (groupname/module).
Thank you for your time!
First of all, as per PSR-0 standard your classnames must have the following structure: \<Vendor Name>\(<Namespace>\)*<Class Name>.
Meaning that your module name should be <Vendor Name>\<Module\Name>
As for template name, by default FQCN of controller is converted to template like this First namespace/controller class name/controller action name
Meaning your Groupa\Module1\Controller\IndexController controller will give you template name groupa/index/index(and not groupa/module1/index/index as you might expect) which will be resolved to file groupa/index/index.phtml in paths defined in template_path_stack
This is default behaviour and it cannot be changed without backwards compatibility break. To mitigate that since zf2.3 there is new setting that will allow you to use modules the way you want.
It is controller_map under view_manager config section.
How to use that you can read here:
https://github.com/zendframework/zf2/pull/5670
'view_manager' => array(
'controller_map' => array(
// Groupa\Module1\Controller\IndexController -> groupa\module1\index\index
// -> module/Groupa/Module1/view/groupa/module1/index/index.phtml
'Groupa\Module1' => true,
),
);
I've got the following problem. I built a PHP file, which reads categories from a file, to impor tthem into Magento. I am able to read the file, no problem. The connection via NuSOAP to the Magento API works aswell. I can get the SessionID and I am able to get data, like Information for a category, also its possible to delete categories.
But, whenever I try to create or update anything, it throws an error. The rights for the user are ok aswell. For example, when I create a category, I add the usual data to the call:
$proxy->call(
$sessionId,
'category.create',
$rootCategory, array(
'name' => "TEST",
'is_active' => '1',
'page_layout' => 'two_columns_right',
'description' => "TEST",
'meta_title' => "TEST",
'meta_description' => '',
'meta_keywords' => "TEST",
'include_in_menu' => '0',
'display_mode' => 'PRODUCTS',
'available_sort_by' => 'price',
'default_sort_by' => 'price',
'is_anchor' => '0'
)
);
All the time, it says:
(
[faultcode] => 102
[faultstring] => Category not exists. )
Which is not true. The $rootCategory is definatly a category, which is existing. I tried all other categories, I tried to add a 'path' to the info, I tried to use less information (only the neccesary stuff), I tried to read existing categories to get their IDs, NOTHING works. It always throws this faultcode.
Same happens, when I try to update a category, or create /update a product. Deleting is no problem at all.
Do you see the problem?
i just compared your NON working exemple and i found this while comparing it with another exemple i has ( i do not pretent to be expert ) ..
but seems like your $new_category, array(blahblha) ...
should be INSIDE an array according to the exemple i already have
like this array($new_category,array(blahblah) ...
this is the mains difference i just saw ..
here is the EXEMPLE i just pulled out of the web ... Adapt to your needs..
$proxy->call(
$sessionId,
'category.create',
array(
3,
array(
'name'=>'New openerp',
'is_active'=>1,
'include_in_menu'=>2,
'available_sort_by'=>'position',
'default_sort_by'=>'position')) );
Have you tried specifying the category_id key in your $rootCategory within the call:
$selectedCategory['category_id'],
array('name'=>'New Category Through Soap')
)
Reference: http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_category
We are currently using the Magento API for importing a bunch of products into the store.
But we now run into a problem where some product attributes should be translated into a different language.
And I was wondering if it is possible to do this using the Magento API, because I can't seem to find anything related to that problem.
We currently have 2 store views, 1 for the Dutch version of the site and one for the French version of the site.
Our current import code looks something like this:
$store_id = $soapClient->call($soapSession, 'catalog_product.currentStore', array('nl'));
echo("store_id: $store_id");
$new_product_data = array(
'name' => 'NameInDutch',
'short_description' => 'DescriptionInDutch',
'price' => $price,
'weight' => $weight,
'websites' => array('base'),
'status' => '1'
);
$new_product_id = $soapClient->call($soapSession, 'catalog_product.create', array('simple', 4, $sku, $new_product_data)); // 4 => 'Default' attribute set
$localized_product_data = array(
'name' => 'NameInFrench',
'short_description' => 'DescriptionInFrench'
);
$store_id = $soapClient->call($soapSession, 'catalog_product.currentStore', array('fr'));
echo("store_id: $store_id");
$soapClient->call($soapSession, 'catalog_product.update', array($sku, $localized_product_data ));
Now, the output of the echo statements differs, the first time it's 1 and the second time it's 2, so that doesn't seem to be problem. But apparently it doesn't matter for the API if we set that value.
The result is that on the 'catalog_product.update' call, the name 'NameInFrench' overwrites the default name 'NameInDutch'.
So my question is if something like this is possible using the Magento API, and how one would accomplish this?
Ok, I found the answer, apparently I overlooked a certain line in the Magento API docs, because the solution was right there.
So: you don't need to set the currentStore each time, you just need to append the store id or code to the update array:
$soapClient->call(
$soapSession,
'catalog_product.update',
array($sku, $localized_product_data, 'fr')
);
This works perfectly.
I get the following SQL error:
SQL Error: 1066: Not unique table/alias: 'I18n__name'
when doing a simple find query.
Any ideas on possible situations that may have caused this??
I'm using a bindModel method to retrieve the data is that related?
This is my code:
$this->Project->bindModel(array(
'hasOne' => array(
'ProjectsCategories',
'FilterCategory' => array(
'className' => 'Category',
'foreignKey' => false,
'conditions' => array('FilterCategory.id = ProjectsCategories.category_id')
))));
$prlist = $this->Project->find('all', array(
'fields' => array('DISTINCT slug','name'),
'conditions' => array('FilterCategory.slug !='=>'uncategorised')
))
You have not used or initialized the required table/model you are using in your controller. Use var $uses = array('your_table_name');
I do not have a direct answer to my problem. However after some research I came to the following conclusion.
I've decided to change my methodology and stop using the translate behavior in cakephp.
I've found another behavior called i18n which works much better when dealing with associated models. You can read about it http://www.palivoda.eu/2008/04/i18n-in-cakephp-12-database-content-translation-part-2/#comment-1380
In cakephp book it says :
"Note that only fields of the model
you are directly doing find on will
be translated. Models attached via
associations won't be translated
because triggering callbacks on
associated models is currently not
supported."
I'm not sure if I made the right choice however I have been struggling to get the translate behavior to work in cakephp and this solution at least makes the project I'm working functional.