I'm using Joomla 3.0 but at this point I can not use component because of a small problem.
This is the error, all other errors I could easily solve by adding Legacy to the class like this JView became JViewLegacy
However for the error beneath I couldn't find a solution:
Any help would be great!
The error:
Fatal error: Call to a member function getParams() on a non-object in
/var/www/g35003/mywebsite.nl/HTML/administrator/components/
com_taxonomy/taxonomy.php on line 16
The code line 16 is marked.
defined( '_JEXEC' ) or die( 'Restricted access' );
global $mainframe;
$params = $app->getParams(); /** <-- Line 16 */
require_once (JPATH_COMPONENT.DS.'controller.php');
$controller = new TaxonomyController();
$controller->execute(JRequest::getCmd('task'));
$controller->redirect();
global $mainframe; has been deprecated since Joomla 2.5 I believe. To get the parameters, you can use the following code:
$params = JComponentHelper::getParams('com_taxonomy');
$test = $params->get('param_name');
Try this
defined( '_JEXEC' ) or die( 'Restricted access' );
$app = &JFactory::getApplication();
$params = $app->getParams(); /** <-- Line 16 */
require_once (JPATH_COMPONENT.DS.'controller.php');
$controller = new TaxonomyController();
$controller->execute(JRequest::getCmd('task'));
$controller->redirect();
For getting the menu item's params in my view I used the following:
$menu = JFactory::getApplication('site')->getMenu()->getActive();
$this->params = $menu->params;
Related
I am using Symfony 3.3.10
I have the following code
/**
* #Route("/meta/edit/{metaId}", name="edit_price_meta_data")
*/
public function editMetaAction(Request $request,ItemPriceMeta $metaId)
{
$metaDataForm = $this->createForm("ItemBundle\Form\ItemPriceMetaType");
$data = [
'metaData'=>$metaId,
'metaDataForm'=>$metaDataForm->createView(),
];
return $this->render("#Item/Prices/Manage/editMetaData.html.twig",$data);
}
It produces the following error.
Error: Maximum execution time of 60 seconds exceeded
in vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php (line 2513)
public function createEntity($className, array $data, &$hints = array()){
$class = $this->em->getClassMetadata($className);
//$isReadOnly = isset($hints[Query::HINT_READ_ONLY])
$id = $this->identifierFlattener->flattenIdentifier($class, $data);
$idHash = implode(' ', $id);
if (isset($this->identityMap[$class->rootEntityName][$idHash])) {
$entity = $this->identityMap[$class->rootEntityName][$idHash];
$oid = spl_object_hash($entity);
The actual line highlighted as causing the error is $id = $this->identifierFlattener->flattenIdentifier($class, $data);
Removing 'metaDataForm'=>$metaDataForm->createView(), from my array, removes the error, so it seems to be the rendering of the form that is causing the error.
Increase PHP memory usage in php.ini
Is there a way to generate URL Keys for all products and save them using a script?
I deleted all URL keys for products from database, but now I want to generate them again using a script.
// Edit: I need to do this in Magento 2. Forgot to specify.
I got this until now:
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
$deploymentConfig = $obj->get('Magento\Framework\App\DeploymentConfig');
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
$repo = $objectManager->get('Magento\Catalog\Model\ProductRepository');
$collection = $productCollection->create()
->addAttributeToSelect('*')
->load();
foreach ($collection as $product){
$name = $product->getName();
$url = preg_replace('#[^0-9a-z]+#i', '-', $name);
$url = strtolower($url);
echo $url;
$pr = $repo->getById($product->getId());
$pr->setUrlKey($url);
$repo->save($pr);
break;
}
But I get this error:
Fatal error: Call to undefined function Magento\Catalog\Model\Config\Source\Product\Options__() in /home2/magazi70/public_html/vendor/magento/module-catalog/Model/Config/Source/Product/Options/Price.php on line 23
<?php
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
$deploymentConfig = $obj->get('Magento\Framework\App\DeploymentConfig');
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$productCollection = $objectManager->create('\Magento\Catalog\Model\Product');
$collection = $productCollection->create()
->addAttributeToSelect('*')
->load();
foreach ($collection as $product){
$product = $objectManager->create('\Magento\Catalog\Model\Product')->load($product->getId());
$name = $product->getName();
$url = preg_replace('#[^0-9a-z]+#i', '-', $name);
$url = strtolower($url);
$product ->setUrlKey($url);
$product->save($pr);
}
The magento script may take longer time.
1. You can try exporting the products (the csv file will not have url keys)
2. Remove all the attributes and keep only SKU and Name and add a new attribute column url_key
3. Use some Excel Functions to generate url keys using Name
4. Remove the Name column
5. Import the csv
to loading a collection and save the new object of product is slow way to done the job
here is best way to
composer require elgentos/regenerate-catalog-urls
php bin/magento module:enable Iazel_RegenProductUrl
php bin/magento setup:upgrade
more information are available on
https://github.com/elgentos/regenerate-catalog-urls
This code shows how to generate an url key, in a helper class, the same way Magento 2 generates url keys when creating products.
In the example I use dependency injection in order to use Magento\Catalog\Model\Product\Url class in my helper.
namespace Myprojects\Mymodule\Helper;
use Magento\Catalog\Model\Product\Url;
use Magento\Framework\App\Helper\Context as HelperContext;
class Data extends AbstractHelper
{
/**
* #param Url $url
*/
public function __construct(
HelperContext $context,
Url $url
)
{
parent::__construct($context);
$this->url = $url;
}
public function generateUrlKey($string)
{
return $this->url->formatUrlKey($string);
}
}
I'm trying to create a dummy login page as a practice. I keep getting this error:
Call to undefined method mysqli_result::fetch_both()
Code:
<?php
if (isset($_POST['LOGIN'])){
$EMAIL = $_POST['loginusernameinput'];
$PASS = $_POST['loginpasswordinput'];
$result = $conn->query("SELECT * FROM userinformationtbl WHERE Email ='$EMAIL' AND password ='$PASS'");
$row = $result -> fetch_both(MYSQLI_BOTH);
session_start();
$_SESSION["userID"] = $row["userID"];
header ('location: account.php');
}
?>
Unless you defined it in your code, fetch_both is not a PHP function.
That's why you get:
Call to undefined method mysqli_result::fetch_both()
PDO::FETCH_BOTH is a constant in the PDO class, which means it can only be used with a PDO connection and PDO functions.
MYSQLI_BOTHis a MySQLi constant.
Fix your code:
$row = $result->fetch_array(MYSQLI_BOTH);
Documentation: mysqli_result::fetch_array
A plugin provides login for a WordPress multi-site network. This plugin now fails under WP 3.5 because the user.php file was changed. The old lines in /wp-includes/user.php can be added back in and the plugin would work. Obviously this is not a long term solution.
This is the old code from user.php
if ( empty( $user ) )
$user = wp_get_current_user();
else
$user = new WP_User( $user );
if ( ! isset( $user->ID ) )
return false;
This is the new code from 3.5
if ( empty( $user ) )
$user = get_current_user_id();
if ( ! $user = get_userdata( $user ) )
return false;
I'm a beginner trying to learn php and so I'm not sure on all of the meanings. However, I think this is the code in the plugin causing issue:
function get_userdata( $user_id ) {
global $wpdb;
if ( ! is_numeric( $user_id ) )
return false;
$user_id = absint( $user_id );
if ( ! $user_id )
return false;
$user = wp_cache_get( $user_id, 'users' ); //check to see if the cache object already has the user
if ( $user )
{
return $user; //it was in the cache
}
$user = new StdClass ();
global $XF;
XF_User_Data::fillUserData($XF->visitor, $user, $user_id);
update_user_caches($user);
return $user;
}
The new StdClass can be commented out and the error is removed but then no one can login.
How could I re-write this function to not cause the error?
*Fatal error: Call to undefined method stdClass::has_prop() /wp-includes/user.php*
The developer of the plugin is 'on vacation' and hasn't updated. He's waiting for some other changes, however, this needs to be fixed.
Any suggestions on fixing the code? Am I looking in the wrong place? Are other details needed before someone can help?
Even if you are a skilled PHP programmer, modifying WP core or any plugin script is really a bad idea. In my opinion, you should downgrade to previous version and wait for the plugin's update. Check this link to do it easily. In fact, many plugins had problems with version 3.5, including the popular CKEditor, but they are being updated and in this case, waiting seems to be the best option. Make sure all plugins are compatible with 3.5 before trying another update.
If you post which plugin you're using and a link to download it I'll take a look at it and see what the issue is.
im trying to use the doctrine pager but its errored:
Fatal error: Class 'Doctrine_Pager' not found
code:
$page = 1;
$results_per_page = 10;
$pager = new Doctrine_Pager(
$query,
$page,
$results_per_page
);
$results = $pager->execute(array(), Doctrine::HYDRATE_ARRAY);
$num_results = $results->getNumResults();
i usually call doctrine EM like this:
$this->_doctrine = Zend_Registry::get('doctrineEm');
$query = $this->_doctrine->createQueryBuilder()
how would i load this doctrine pager?
Its my understanding that the pager from 1.2 has been removed from doctrine2.
However, you can add "doctrine extensions" to the ORM which will give you that functionality.
https://github.com/beberlei/DoctrineExtensions